easy_localization icon indicating copy to clipboard operation
easy_localization copied to clipboard

Plural categories don't work as they should

Open Albert221 opened this issue 4 years ago • 5 comments

Hi! Plurals don't work as expected, I'm not sure about all cases, but here's my example:

{
  "view_count": {
    "one": "{} view",
    "other": "{} views"
  }
}

As you can see, I provided all plural categories for English (according to 2nd source), but for some reason, easy_localization tries to use the zero category as well for a value of 0.

[🌎 Easy Localization] [WARNING] Localization key [view_count.zero] not found<…>
[🌎 Easy Localization] [WARNING] Fallback localization key [view_count.zero] not found<…>

Other than that, the library serves me well, but this bug is really annoying because my translation service allows translating only the plural categories a given language uses (so for English that's only one and other).

Cause

This is most likely due to:

https://github.com/aissat/easy_localization/blob/f4f3ce803a38f78316af1fa57dd91484a8bd6494/lib/src/localization.dart#L121-L130

I believe this was to mimic the behavior of =0, =1 or =2 from the ICU plurals syntax (3rd source), but this should fall back to the ordinary plural categories. And not use the same name as the zero, one or two plural categories, as one might want to have a specific string set for a value of 1, but for example, one category in Ukrainian is also used for 21, 31, 41...

Sources

  1. http://cldr.unicode.org/index/cldr-spec/plural-rules
  2. https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html
  3. https://unicode-org.github.io/icu/userguide/format_parse/messages/#complex-argument-types

Related

  • #352

Albert221 avatar Apr 28 '21 07:04 Albert221

Waiting for this fix. I can't release my app without this fix.

HugoSart avatar Jun 09 '21 21:06 HugoSart

Hello, is there a progress on this issue?

ValentinVignal avatar Sep 21 '21 06:09 ValentinVignal

It has been fixed and merged, but still not released

shilangyu avatar Sep 21 '21 06:09 shilangyu

Any updates?

haytham-c01 avatar Dec 07 '21 20:12 haytham-c01

Looks like it has been released with 3.0.1-dev

shilangyu avatar Mar 08 '22 11:03 shilangyu