Comments (6)
Same here, it's a regression in version 3.0.4 (3.0.3 works correctly).
from easy_localization.
@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?
from easy_localization.
Same here, I have to downgrade it to 3.0.3
from easy_localization.
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 plural_rules.dart
. These rules are written from The Unicode CLDR (Common Locale Data Repository), and only a few languages have a specific rule for zero.
If your selected language does not have a specific rule for zero, it will use the "one" or "other" translation. Example for English:
PluralCase _en_rule() {
if (_i == 0 || _i == 1) {
return ONE;
}
return OTHER;
}
I used to do something like this, which does not work anymore:
{
"zero": "No card",
"one": "1 card",
"other": "{} cards"
}
To fix this, we have to use it like this:
{
"zero": "No card",
"one": "{} card",
"other": "{} cards"
}
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.
from easy_localization.
I have sent PR #668 for this: there's a new forcePluralCaseFallback
option that can be set to true
to enable the "legacy" behavior (pre-3.0.4). It defaults to false
though, so that the new behavior is still used by default.
runApp(EasyLocalization(
// ...
forcePluralCaseFallback: true,
child: ...
));
from easy_localization.
Commenting for clarity: after upgrading to easy_localization 3.0.7 you'll get the "old" behavior by default, with an option (ignorePluralRules
) to switch to the new one.
So, if you have
"label_members": {
"zero": "nobody",
"one": "{} member",
"two": "{} members",
"other": "{} members"
},
then
LocaleKeys.label_members.plural(0)
will give
- on easy_localization up to 3.0.6:
nobody
- on easy_localization 3.0.6:
0 members
- on easy_localization 3.0.7:
nobody
- on easy_localization 3.0.7 with
ignorePluralRules: false
:0 members
from easy_localization.
Related Issues (20)
- BottomNavigationBarItem lable not change the language HOT 2
- Need callback finish EasyLocalization -> Load asset from assets/translations
- How can i create custom locals for unsupported langauges?
- How to change default "DateFormat('d').format" format HOT 1
- intl 0.19.0 doesn't work with easy_localizaiton version 3.0.5 HOT 10
- Missing features about easy localization HOT 1
- French translation Special Cahracters are not displayed correctly HOT 1
- How to set mutiple language for mutiple package in project?
- context.setLocale reverse to previous language with Easy localization HOT 1
- [Feature Request] ARB support for localization
- [Feature Request]: Support namespaces / multiple files per language
- resetLocal crashes if deviceLocale not in supportedLocales HOT 2
- ignore_for_file: constant_identifier_names when generate locale_keys.g.dart
- Localization not working on physical device
- strict countryCode problem HOT 2
- Can we generate locale keys in record form? HOT 12
- When using Icelandic (is), the automatically generated code conflicts with the keyword 'is' HOT 1
- Changing system language does not effect HOT 1
- Using macros to generate the LocaleKeys? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy_localization.