You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
However, problem 2 is more fundamental. I would like to get input on this. One idea is to use $ placeholders in a string and allow the translate methods to take parameters. In this case, the example above would look something like this:
There are two problems in implementation of localization.
Problem 1. Translate function requires from us to know full and strange keys like this:
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:
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.
The text was updated successfully, but these errors were encountered: