flutterdartmobilelocaleflutter-easy-localization

Flutter package easy_localization plurals not working as expected


Using the package easy_localization for my apps translations. As an example here is the translations file json:

{"test": {
"zero": "zero",
"one": "one",
"two": "two",
"few": "few",
"many": "many",
"other": "other"},}

If I then simple print these to the console like so:

print(plural("test", 0));
print(plural("test", 1));
print(plural("test", 2));
print(plural("test", 3));
print(plural("test", 4));

it will return

zero
one
two
other
other

So it works for "zero", "one", "two" as expected. But then skips "few" and "many" and defaults to "other".

What constitutes "few" and "many"? Am I to take "other" as being used for plurals and ignore "few" and "many"?

There's no errors so I am not sure if this was the intended functionality. Feels wrong to me.

If anyone has had experience with this package, would be great if they could explain the reasoning for this.


Solution

  • You can see what the plural rules are in their source code.

    It seems most languages have very simple plural rules. Like English, where it's basically none, one or other: You can have "no money" "a dollar" or "X dollars". English does not have special language for other amounts.

    I'm afraid I don't know any of the languages that do have special rules for special amounts. But if you ever have to translate for them, the person speaking the language will know for sure.