Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plural translation wrong #10

Open
jlocans opened this issue Apr 14, 2016 · 5 comments
Open

Plural translation wrong #10

jlocans opened this issue Apr 14, 2016 · 5 comments

Comments

@jlocans
Copy link

jlocans commented Apr 14, 2016

ICatalog catalog = new Catalog("lv", "./locale", new CultureInfo("lv"));
Console.WriteLine(catalog.GetString("My name is {0}"), "Enzo");
int i = 0;
Console.WriteLine(catalog.GetPluralString("I'm {0} year old.", "I'm {0} years old.", i), i);
i = 21;
Console.WriteLine(catalog.GetPluralString("I'm {0} year old.", "I'm {0} years old.", i), i);
i = 22;
Console.WriteLine(catalog.GetPluralString("I'm {0} year old.", "I'm {0} years old.", i), i);

Those are translated to latvian which has (nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);) using Poedit.
Console prints: (in paranthesis I have added from which translation it comes)

Mani sauc Enzo
Man ir 0 gads. (n -> 1, 21, 31, 41 translation)
Man ir 21 gadu. (n -> 2, 3, 4, 5.. translation)
Man ir 22 gadu. (Zero translation)

I really don't care about '0' case, because that's the first time I hear my native language has 3 types of those, but anyway, they are all wrong! xgettext prints this correctly.

@VitaliiTsilnyk
Copy link
Owner

Where did you get that plural form expression?
By default, NGettext uses precompiled plural formulas and for the "lv" locale it looks different:

 (n == 0) ? 0 : (((n % 10 == 1) && (n % 100 != 11)) ? 1 : 2)

You can correct your poedit formula or enable plural formula reader to read it from your mo file.

@jlocans
Copy link
Author

jlocans commented Apr 14, 2016

It is Poedit's default. The same as you can find on http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms

You can correct your poedit formula or enable plural formula reader to read it from your mo file.

You mean like this?
ICatalog catalog = new Catalog(new MoCompilingPluralLoader("Example", "./locale"));
If so, I didn't find a way to specify CultureInfo.

@VitaliiTsilnyk
Copy link
Owner

NGettext uses the Unicode CLDR project data for plural form formula generation. But now it's outdated (see issue #4). And still, cldr provides formula different from yours. Form with 0 index is used for 0-type values, index 1 — for numhers ending with 1, and index 2 for others.
If you want, you can suggest different plural form expression provider so I can use it for generation of precompiled plural forms.

@VitaliiTsilnyk
Copy link
Owner

If so, I didn't find a way to specify CultureInfo.

It's the second parameter of the Catalog constructor in your case.

@jlocans
Copy link
Author

jlocans commented Apr 14, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants