Closed Bug 1415842 Opened 2 years ago Closed 2 years ago

[compare-locales] Add mappings of locales to StringBundle's plural rules

Categories

(Localization Infrastructure and Tools :: compare-locales, enhancement)

enhancement
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: stas)

References

Details

Attachments

(1 file)

Let's add mapping of locale codes to plural rules from https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals, including the order of plural categories for each rule.

This will be useful for checks run on legacy translations as well as for migrating pluralized variants in the proper order.
Blocks: 1415844
We're adding one more form in bug 1396724. 17, ['zero', 'other'], for `jiv`.
Blocks: 672031
See Also: → 1396724
Passing by note: maybe safer to refer to?
http://searchfox.org/mozilla-central/source/intl/locale/PluralForm.jsm

MDN: #3 is missing, Latvian is associated to #6
Code: #3 is Latvian

lv and ltg are indeed using rule number #3
https://transvision.mozfr.org/string/?entity=toolkit/chrome/global/intl.properties:pluralRule&repo=gecko_strings

I've added #17 to MDN, I'm going to add #3.
Yup, good point. That was also the plan from my convo with Axel yesterday.
Hmm, actually, Latvian might not be a good example of the different ordering. If I'm reading rule #3 right:

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

The return values (0, 1, 2) map to (zero, one, other).

NB. according to the CLDR, the rule implemented in PluralsRules.jsm is wrong. It returns "other" for 20, 30 etc. CLDR says it should be "zero".
(In reply to Staś Małolepszy :stas from comment #4)
> Hmm, actually, Latvian might not be a good example of the different
> ordering. If I'm reading rule #3 right:
> 
>     (n) => n%10==1&&n%100!=11?1:n!=0?2:0
> 
> The return values (0, 1, 2) map to (zero, one, other).
> 
> NB. according to the CLDR, the rule implemented in PluralsRules.jsm is
> wrong. It returns "other" for 20, 30 etc. CLDR says it should be "zero".

Indeed
http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#lv

The current rule only use 0 for 0, not anything ending in 0. Filed bug 1415896.
Thanks, flod.

I found a better example: in PluralRules.jsm, Arabic is described as:

    // 12: Arabic
    [6, (n) => n==0?5:n==1?0:n==2?1:n%100>=3&&n%100<=10?2:n%100>=11&&n%100<=99?3:4],

The "zero" category is returned as "5".
Riiight, we added the zero after the fact, and wanted to do so without invalidating existing translations. That's why we appended the zero case as last case.
:) I imagined that was the story behind it.

I went through all of the rules in PluralForm.jsm and I found the following discrepancies:

  - Polish (rule #9) has 3 categories while CLDR says 4,
  - Arabic (rule #12) has "zero" as the last variant,
  - Macedonian (rule #13) has 3 categories while CLDR says 2.

Not too bad. I'll double check everything again.
Depends on: 1415906
Depends on: 1415896
Comment on attachment 8927297 [details]
Bug 1415842 - Map locales to plural categories as per PluralForm.jsm.

https://reviewboard.mozilla.org/r/198608/#review203734

Thanks, looks like a good enabler to more patches.
Attachment #8927297 - Flags: review?(l10n) → review+
https://hg.mozilla.org/l10n/compare-locales/rev/f521f9cd882d382e88d9910faeaca2055d63b552
Bug 1415842 - Map locales to plural categories as per PluralForm.jsm. r=Pike
Assignee: nobody → stas
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.