Skip to content
tezvyn:
Menu

How do you handle UI text pluralization with ICU Message Format?

Source: unicode-org.github.ioEasyHow cards are made

This tests i18n depth beyond adding an 's'. A strong answer names ICU MessageFormat, lists the six CLDR plural cases, and notes translators provide strings per case. Red flag: hard-coding suffixes or simple if/else logic that breaks in Polish or Arabic.

What's really being asked

This question checks whether you treat internationalization as a first-class engineering concern rather than an afterthought. Even senior engineers sometimes expose English-centric assumptions in UI code. The interviewer wants to see that you know plural forms vary dramatically across languages and that you rely on standardized data rather than reinventing locale logic.

The full answer

First, name a standard library such as ICU MessageFormat, FormatJS, or i18next with ICU plugins. Second, explain that these libraries use CLDR plural rules which define six keyword categories: zero, one, two, few, many, and other. Third, describe the pattern structure where each keyword maps to a full message string provided by translators, not just a suffix. Fourth, note that the library evaluates the numeric input against locale-specific rules to select the correct keyword, so the code itself never contains language-specific branching. Fifth, mention that an unquoted pound sign in the pattern is replaced by the formatted number, and that offsets can shift the value used for selection.

The mistakes people make

Hard-coding a ternary check like count equals one then item else items is the classic failure because it breaks on languages with multiple plural forms such as Polish or Arabic. Another red flag is suggesting string concatenation where the code appends an s or a translator-supplied suffix; this assumes English grammar and word order. Proposing ChoiceFormat-style numeric intervals is also wrong because languages like Polish have paucal cases that apply to non-contiguous number patterns, which interval logic cannot express.

What usually comes next

The interviewer may ask how you would handle pluralization in a language with no plural forms at all, such as Japanese or Korean, where the other case covers everything. They might also probe how you combine plural arguments with gender or select expressions in a single MessageFormat pattern, or how you keep translation keys manageable when every plural case requires a distinct string. Be ready to discuss extraction workflows where translators see the full pattern rather than isolated fragments.

A concrete example

In ICU MessageFormat, a Polish inventory message looks like this: You have {count, plural, one {# produkt} few {# produkty} many {# produktów} other {# produktu}}. The keyword one covers 1, few covers 2 through 4 and numbers ending in 2 through 4 excluding teens, many covers 0 and 5 through 21 and numbers ending in 0 or 5 through 9 and teens, and other serves as the fallback. The same pattern structure works for English with only one and other defined, demonstrating that the application code remains identical while CLDR rules handle locale complexity.

Interview question

When implementing pluralized UI text with ICU MessageFormat, what should the code do to support languages with complex plural rules like Polish or Arabic?

  • a.Use locale-specific numeric intervals to choose between different message fragments
  • b.Append a translator-provided suffix to a base string based on the numeric count
  • c.Rely on a ternary check for count equals one and otherwise use a generic plural form
  • d.Map each CLDR plural case to a complete translator-provided string and let the library select based on locale rulesCorrect
Why?

ICU MessageFormat relies on CLDR plural categories where translators supply full strings per case, and the library selects the correct form without language-specific branching in code. Option C is the most common misconception, breaking immediately in languages like Polish or Arabic that have multiple plural forms beyond a simple one/other split.

Just read this? Test yourself on what you have been reading.

Read the original → unicode-org.github.io

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles