[BUG] `I18n::Backend::Pluralization` should support CLDR pluralization
movermeyer opened this issue · 1 comments
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::Pluralization
has an incorrect special case forcount == 0
, which returnszero
, which is the incorrect key to use for count == 0 in many locales- e.g.,
ar
requires the use ofzero
key, so if you usezero
inen
, the translation of theen
zero
value intoar
will conflict with the translation for thezero
key produced by translating theen
one
andother
keys.
- e.g.,
-
CLDR allows for explicit plural rules that exactly match
count == 0
andcount == 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
zero
today in locales that don't use thezero
key (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
other
plural rule before falling back to an ancestor locale - Without this behaviour, as a user you have to pre-process the data to copy the
other
key 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::Pluralization
would be a breaking change. While I'm personally in favour of this change (i.e., forcing users to rename their already problematiczero
keys to"0"
), obviously this is your call.
Should this be re-opened now that #630 was reverted?