carp-dk / carp-dk/research.package

Localizations improvement

Open
#42 1 comment 3 reactions 0 assignees View on GitHub
enhancement question
Dominant language
Dart
Stars
52
Forks
47
Avg merge
5h 35m
Merged PRs (30d)
4

Description

There are two problems in implementation of localization.

Problem 1. Translate function requires from us to know full and strange keys like this:
```
locale?.translate(
’Review this form below, and tap AGREE if you\’re ready to continue.’) ??
’Review this form below, and tap AGREE if you\’re ready to continue.’,
```
Problem 2. Current implementation can’t properly handle cases when we need to insert variable into random place of the string. RP just concatinates sequance of texts and variables but some languages might require to change the order of words. For example:
```
_errorMessage =
“${locale?.translate(‘Should be between’) ?? ‘Should be between’} ${widget.answerFormat.minValue}
${locale?.translate(‘and’) ?? ‘and’} ${widget.answerFormat.maxValue}“;
```

Working on the private fork of research package repo for company we faced these issues.
There are great solution to solve these problems.
Solution for Problem 1. Use getters in RPLocalization, for example:
`String get reviewAndAgreeToContinue => translate(“reviewAndAgreeToContinue”);`
Solution for Problem 2. Use functions similarly to getters, like this one:
`String valueShouldBeBetween(Object minValue, Object maxValue);`

Our main goals are to stay closer to Flutter internationalization and improve your package. If anybody interested in this idea please let me know and I will create PR soon.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing RPLocalization and the translate calls shown in the issue, then compare the proposed getter and function APIs with Flutter internationalization. Define how stable localization keys and reordered variable interpolation should work, and document the resulting API expectations before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
internationalization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.