i18n
i18n copied to clipboard
[BUG] `I18n::Backend::Pluralization` should support CLDR pluralization
ruby-i18n/i18n should ship with a pluralization backend compatible with CLDR.
Especially when the README advertises it as such:
The default I18n::Backend::Pluralization does not support CLDR's pluralization rules.
Differences with the CLDR spec:
-
I18n::Backend::Pluralizationhas an incorrect special case forcount == 0, which returnszero, which is the incorrect key to use for count == 0 in many locales- e.g.,
arrequires the use ofzerokey, so if you usezeroinen, the translation of theenzerovalue intoarwill conflict with the translation for thezerokey produced by translating theenoneandotherkeys.
- e.g.,
-
CLDR allows for explicit plural rules that exactly match
count == 0andcount == 1, independent of locale:"0": I don't have any cars # Used for count == 0, taking precedent over locale-specific rules "1": I have a single car # Used for count == 1, taking precedent over locale-specific rules one: I have %{count} car other: I have %{count} cars- i.e., People who are using
zerotoday in locales that don't use thezerokey (e.g.,en), should be using the explicit"0"key instead.
- i.e., People who are using
-
When a lookup for a plural case key fails, a Lateral Inheritance lookup should occur within the same locale before falling back to a Locale Inheritance (
I18n::Backend::Fallbacks) lookup in a parent locale.- e.g. it falls back to using the
otherplural rule before falling back to an ancestor locale - Without this behaviour, as a user you have to pre-process the data to copy the
otherkey into any missing plural rules
- e.g. it falls back to using the
Limitations
-
We don't currently have a defined standard way to serialize the other lateral inheritance attributes (e.g.,
case,gender) present in the CLDR XML into YAML. If/when we figure out how to support those, that would be a future change. -
Making these changes to
I18n::Backends::Pluralizationwould be a breaking change. While I'm personally in favour of this change (i.e., forcing users to rename their already problematiczerokeys to"0"), obviously this is your call.
Should this be re-opened now that #630 was reverted?