0

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.

Michael Johnston
  • 718
  • 2
  • 11
  • 25

1 Answers1

1

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.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Ah I think I understand it a bit better now after looking at that source code. Was getting really confused on why so many of the same thing. Looking at the Arabic (PluralCase _ar_rule()) function for instance they have a use for every type (zero, one, two, few, many). Whereas the English function literally only has "one" then defaults to "other" which I presume you make as the plural. I didn't realize that depending on the current locale the functions would change for plurals. Thanks for directing me to that source code :) – Michael Johnston Apr 17 '23 at 13:34
  • I think maybe the English function should have "one" and "many" then default to "other", but thats a small thing as I'll just use "other" as the plural form variable for English at least. – Michael Johnston Apr 17 '23 at 13:35