fix(ru,uk,be): correct plural form for counts ending in 11-14#288
Open
spokodev wants to merge 1 commit into
Open
fix(ru,uk,be): correct plural form for counts ending in 11-14#288spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
The plural selector used `n > 20` / `n < 10` heuristics that skip the teens in the higher hundreds, so counts such as 112 years rendered with the "few" form (112 года/роки/гады) instead of the required "many" form (112 лет/років/гадоў). Guard the 11-14 range with `n % 100`, matching CLDR (Intl.PluralRules) and this repo's own sr.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Russian, Ukrainian and Belarusian plural selectors decide the "one" and "few" forms with
n > 20/n < 10heuristics. Those checks skip the teens once you pass 100, so any count whose last two digits are 11-14 gets the wrong form. In East-Slavic grammar 11-14 always take the "many" form, regardless of the hundreds.Since seconds/minutes/hours/days/weeks/months are capped below 100, this only surfaces on year counts, e.g.:
Oracle -
Intl.RelativeTimeFormat/Intl.PluralRules(CLDR): 111, 112, 113, 114 are all categorymanyin ru/uk/be, so they must use the same form as 5-20 ("лет"/"років"/"гадоў"), not the "one"/"few" forms.The fix guards the 11-14 range with
n % 100, the same approachsr.tsalready uses in this repo. Verified againstIntl.PluralRules('ru')over 1..100000: the old code mismatched 3996 values, the new code mismatches 0, and behaviour only changes for counts ending in 11-14 in the hundreds (111-114, 211-214, ...). All existing values (1, 2-4, 5-20, 21-24, ...) are unchanged.Adds a regression test to each locale's spec.