-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using plural(0) count as other #648
Comments
Same here, it's a regression in version 3.0.4 (3.0.3 works correctly). |
@aissat any update on this issue? Looks like you made a new release but this fix is not included... it's a major regression so I think it should have priority over new feature, right? |
Same here, I have to downgrade it to 3.0.3 |
Same thing, still present in 3.0.5. But this is not a bug, this is a feature 🤓 This is present since this PR: #620, which now takes into account pluralization according to language. easy_localization/lib/src/localization.dart Lines 140 to 141 in 63a3974
Pluralization is now based on the rules in If your selected language does not have a specific rule for zero, it will use the "one" or "other" translation. Example for English:
I used to do something like this, which does not work anymore:
To fix this, we have to use it like this:
As you can see, the bad news here is we can't no longer use "zero", unless the language has a specific rule. To me, it will be nice to include "zero" to every language, to be able to display a custom translation in this case. |
…ation Add forcePluralCaseFallback option to force evaluation of fallback plural rules, i.e. * forcePluralCaseFallback: false Default behavior, will use "zero" rule for 0 only if the language is set to do so (e.g. for "lt" but not for "en"). * forcePluralCaseFallback: true Force using "zero" rule for 0 even if the language doesn't use it by default (e.g. "en"). If "zero" localization for that string doesn't exist, "other" is still used as fallback.
I have sent PR #668 for this: there's a new
|
Commenting for clarity: after upgrading to easy_localization 3.0.7 you'll get the "old" behavior by default, with an option ( So, if you have "label_members": {
"zero": "nobody",
"one": "{} member",
"two": "{} members",
"other": "{} members"
}, then LocaleKeys.label_members.plural(0) will give
|
I have this json:
"test": {
"zero": "0Test",
"one": "1Test",
"many": "many{digit} Tests",
"other": "other{digit} Tests"
}
when i use LocaleKeys.test.plural(0) it outputs as other
The text was updated successfully, but these errors were encountered: