Localizely logo
  • Home
  • Getting started
  • How it works
  • Pricing
  • FAQ
Sign up

I18n questions · ICU message format

How do I combine gender and count in one ICU message? 

Nest one argument inside the other so that each combination of gender and count is a full sentence. ICU recommends putting the select on the outside and a single plural inside, because the set of genders is fixed and small while the plural categories vary by language:

{gender, select,
  female {{count, plural, one {She has # cat} other {She has # cats}}}
  male {{count, plural, one {He has # cat} other {He has # cats}}}
  other {{count, plural, one {They have # cat} other {They have # cats}}}}

With gender set to male and count to 3 this prints He has 3 cats; female and 1 prints She has 1 cat.

The reason for whole sentences is grammar. In many languages the verb, an adjective or the noun agrees with both gender and number, and the word order changes between forms. A translator who receives complete sentences per branch can rewrite each one freely; a translator who receives She, has and cat as separate strings that the code glues together cannot. The ICU user guide puts it as "use complex arguments as the outermost structure of a message, and write full sentences in their sub-messages".

# is replaced only in text that sits directly inside a plural branch, so in the example it always means count. If you nest the other way round, a plural outside and a select inside, ICU prints a # inside the select literally; write {count} there instead, or keep the recommended order.

Keep the nesting to two levels. Every level multiplies the number of sentences a translator has to write: three genders times the four Russian categories is already twelve, and a third dimension such as the item type makes it thirty-six or more. If a message needs that, split it into separate messages or rephrase it so that one variable no longer changes the wording.

Pitfalls:

  • Every level needs its own other branch, or the message fails to parse.
  • The closing braces pile up at the end (}}}} in the example); an editor that validates the syntax, such as the ICU message editor, catches an unbalanced one.
  • A select value must match the keyword exactly, so pass female, not Female, or the branch for other is shown.

Published Oct 9, 2026 · Markdown version

Related ICU message format questions:

ICU message format guide:

Read the quick guide to ICU message format
Localizely logo
About
Free tools
Boring stuff
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Compare
Newsletter
Copyrights 2026 © Localizely