ICU Selectordinal for Rankings and Ordinal Numbers

Use ICU selectordinal to format ordinal numbers (1st, 2nd, 3rd) correctly across languages. Covers English ordinal suffixes and language-specific ordinal rules.

Plural & Select

Detailed Explanation

Ordinal Numbers with ICU Selectordinal

The selectordinal argument type handles ordinal number formatting -- numbers that indicate position or rank (1st, 2nd, 3rd, 4th, etc.). Like plural, it uses CLDR rules, but for ordinal rather than cardinal numbers.

Basic English Ordinals

You finished in {place, selectordinal,
    one {#st}
    two {#nd}
    few {#rd}
    other {#th}
} place!

Results:

  • place=1 -> "You finished in 1st place!"
  • place=2 -> "You finished in 2nd place!"
  • place=3 -> "You finished in 3rd place!"
  • place=4 -> "You finished in 4th place!"
  • place=11 -> "You finished in 11th place!" (not 11st)
  • place=21 -> "You finished in 21st place!"
  • place=22 -> "You finished in 22nd place!"

English Ordinal Rules

English ordinal categories are determined by the last digits:

Category Numbers Suffix
one 1, 21, 31, 41, ... (but NOT 11) -st
two 2, 22, 32, 42, ... (but NOT 12) -nd
few 3, 23, 33, 43, ... (but NOT 13) -rd
other 0, 4-20, 24-30, 11, 12, 13, ... -th

Ordinals in Other Languages

Many languages have simpler ordinal systems:

French -- uses only one and other:

{place, selectordinal,
    one {#er}
    other {#e}
}
  • 1er, 2e, 3e, 4e, ...

Italian -- all ordinals are the same:

{place, selectordinal,
    other {#°}
}

Swedish -- uses one and other:

{place, selectordinal,
    one {#:a}
    other {#:e}
}

Combined with Context

{name} finished {place, selectordinal,
    one {#st}
    two {#nd}
    few {#rd}
    other {#th}
} in the {eventName}.

Exact Match Override

Like plural, you can use =N for exact values:

{place, selectordinal,
    =1 {gold medal}
    =2 {silver medal}
    =3 {bronze medal}
    other {#th place}
}

When to Use Selectordinal vs Manual Strings

Use selectordinal when you need locale-aware ordinal formatting. If your ordinals are always in a fixed context (like "Chapter 1", "Chapter 2"), you might not need selectordinal since many languages do not use ordinal suffixes in that context. Consult your translators to decide.

Use Case

Developers building leaderboards, rankings, competitions, or any feature that displays positional numbers (1st place, 2nd highest score) that must render correctly in multiple languages.

Try It — ICU Message Format Tester

Open full tool