Translating Dynamic Values, Pluralization, and Dates
Basic word-for-word string translation breaks down when handling grammatically complex linguistic rules. Different human languages possess completely different rules for pluralization (e.g. English has 2 plural forms, Arabic has 6, Japanese has 0), dynamic currency formatting, and localized calendar dates. Handling these correctly requires combining i18next with the native browser Intl API.
1. Enterprise Pluralization Rules
In English, pluralization is binary (1 item vs many items). In other languages (Russian, Polish, Arabic), nouns change forms based on specific numerical remainder patterns:
JSON
1// public/locales/en/common.json
2{
3"itemCount_one":"You have {{count}} item in your cart",
4"itemCount_other":"You have {{count}} items in your cart",
5"itemCount_zero":"Your shopping cart is completely empty"
6}
JSON
1// public/locales/ar/common.json (Arabic has 6 plural forms!)
2{
3"itemCount_zero":"سلتك فارغة",
4"itemCount_one":"لديك عنصر واحد في سلتك",
5"itemCount_two":"لديك عنصران في سلتك",
6"itemCount_few":"لديك {{count}} عناصر في سلتك",
7"itemCount_many":"لديك {{count}} عنصراً في سلتك",
8"itemCount_other":"لديك {{count}} عنصر في سلتك"
9}
When invoking t(), pass count:
TSX
1// React automatically selects the correct linguistic plural form!
2<p>{t("itemCount",{ count: items.length })}</p>
2. Number and Currency Localization via Intl.NumberFormat
Never format currency with hardcoded dollar signs ($${amount}). Different countries format numbers differently (e.g. $1,250.50 in the US vs 1.250,50 € in Germany):