Flutter软件包easy_localization复数形式不如预期工作。

huangapple go评论74阅读模式
英文:

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.

英文:

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.

答案1

得分: 1

你可以在它们的源代码中查看复数规则是什么。

似乎大多数语言都有非常简单的复数规则。就像英语一样,基本上是没有、一个或其他:你可以说“没有钱”、“一美元”或“X美元”。英语没有针对其他数量的特殊语言。

恐怕我不知道任何具有特殊数量规则的语言。但如果你不得不为它们翻译,讲这种语言的人肯定会知道。

英文:

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.

huangapple
  • 本文由 发表于 2023年4月17日 19:32:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76034716.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定