intermediate
Plurals
Use ICU-style plural rules and localized message structure so counts, gender, cases, and grammar stay correct across languages.
Plural rules vary by language: English has one/other; Russian has one/few/many; Arabic has more categories. ICU MessageFormat and libraries like FormatJS handle `{count, plural, ...}` instead of `if (n === 1)` in application code.
{count, plural,
=0 {No messages}
one {# message}
few {# messages}
many {# messages}
other {# messages}
}
| Anti-pattern | Why it fails | |--------------|--------------| | `count + " items"` | Word order and grammar differ | | English rules globally | Slavic and Arabic need extra branches | | Splitting sentence across keys | Translators cannot reorder words |
Keep full sentences in one message id; pass variables for count, names, and gender when grammars require agreement.
On interviews: CLDR plural categories; i18next vs FormatJS; extracting messages for translators; plural + select combined messages.
Common pitfalls: concatenating subject and object separately; missing `=0` branch; not testing `21` in Russian (one form) vs `22` (few); pluralizing in JSX instead of catalog.
The trade-off is translator workflow complexity versus grammatically correct UI in every locale.
Checklist:
- One message owns the whole sentence.
- Use ICU plural/select in catalogs.
- Test 0, 1, 2, 5, 21 across target locales.
- Avoid string math in components.