gotchajavascriptMajor
Pluralization Rules Vary Drastically by Language
Viewed 0 times
plural rulesCLDRIntl.PluralRulesarabic pluralpluralization i18nplural forms language
Problem
An app built with only singular/plural logic (English assumption) breaks for Arabic (6 forms), Russian (3 forms), and Chinese (1 form).
Solution
Always use the CLDR plural rules via
Intl.PluralRules or your i18n library. Never write custom plural if/else logic.// Native Intl.PluralRules
const pr = new Intl.PluralRules('ar'); // Arabic
pr.select(0) // 'zero'
pr.select(1) // 'one'
pr.select(2) // 'two'
pr.select(5) // 'few'
pr.select(11) // 'many'
pr.select(100) // 'other'
// WRONG — hardcoded English binary logic
const label = count === 1 ? 'item' : 'items';
// CORRECT — use ICU in your translation string and let the library handle it
// en.json: { "items": "{count, plural, one {# item} other {# items}}" }Why
The Unicode CLDR defines plural categories per language. Software that hardcodes English binary logic cannot be correctly translated into Slavic, Semitic, or East Asian languages.
Gotchas
- Chinese, Japanese, Korean, and many other languages have only one plural form — do not force translators to provide forms that do not exist.
- Ordinals (1st, 2nd, 3rd) use different CLDR rules than cardinals — use
Intl.PluralRules('en', { type: 'ordinal' }). - Zero is a special plural category in Arabic and some other languages —
=0in ICU syntax handles it explicitly. - Always test with real translators — machine translation often produces grammatically incorrect pluralization.
Revisions (0)
No revisions yet.