A quiz app finishes a round and tells the player "You finished 2nd." In English that works. In French the screen says "2nd" next to French copy, in Spanish it says "2nd" where a reader expects 2.º, and in Japanese it shows a Latin suffix in the middle of a sentence that would never use one. The code that produced all three is usually a dozen lines that look correct: take the number modulo 10, special case 11 to 13, return st, nd, rd, or th.
That helper encodes English grammar. This guide shows how to replace it with locale rules and translatable messages, where platform formatters help, where they do not, and which numbers to put in your tests.
The short answer
Do not build ordinals from a number plus a suffix. Put the whole phrase, including the noun it describes, in a translatable message that uses ICU selectordinal, or select the CLDR ordinal category with Intl.PluralRules (type: "ordinal") or Android PluralRules (PluralType.ORDINAL) and key complete strings by that category. Use standalone ordinal formatters such as Apple's NumberFormatter.Style.ordinal or ICU's rule-based ordinal format only where the ordinal stands alone, in the app's selected locale. Let translators drop the ordinal entirely when their language prefers another construction, and test the numbers each language's rule branches on.
Why the English helper keeps shipping
The suffix helper is easy to write and easy to test in English. One example is GitHub issue Ralex91/Razzia #216, which proposes a getOrdinalSuffix function that returns th for 11 to 13 and otherwise st, nd, rd, or th from the last digit. The same screen already uses react-i18next for its other strings, so the rank's English suffix is interpolated into otherwise translated text and never reaches a translator.
The question of how to localize that suffix has been asked for a long time. A 2010 Stack Overflow question, localize ordinal numbers, asks whether gettext has a function that returns the suffix for the current language. A 2018 question about an Angular pipe, Javascript ordinal suffix locale translation, proposes reading st, nd, rd, and th from a file per locale and asks whether that assumption holds for other languages. Another asks for localized ordinal numbers in Java and notes that 10 is 10th in English but 10.º in Spanish. These are practitioner reports, and each one starts with an English rule and then tries to translate its output.
Dates make the problem less visible. Expensify's issue #98088 lists display formats that hardcode US conventions, including a MMMM do, yyyy format with an ordinal day. The report notes that date-fns returns a bare number with no ordinal marker for Polish and Italian, and suggests the ordinal may not be worth keeping in non-English locales. So an ordinal that looks fine in the English build can come out differently in other locales without any error.
What CLDR says ordinals actually look like
Ordinal forms are defined per language in the Unicode CLDR language plural rules chart, separately from the cardinal rules used for "1 item, 2 items." A few rows from that chart show why a suffix table cannot be the model:
- English has four ordinal categories:
one(1, 21, 31, but not 11),two(2, 22, but not 12),few(3, 23, but not 13), andother. The chart's examples are "Take the 1st right" through "Take the 4th right." - Welsh has six ordinal categories, from
zerothroughmanyandother. - Italian has a
manycategory for 8, 11, 80, and 800, with the example "Prendi l'8° a destra" against "Prendi la 7° a destra." The difference is in the article before the number, not in a suffix. - Swedish uses
1:aand2:afor numbers ending in 1 or 2 (except 11 and 12) and3:efor the rest. - French has
oneonly for 1, with the example "Prenez la 1re à droite," andotherfor everything else, as in "Prenez la 2e à droite." - Japanese has a single ordinal category,
other.
MDN's Intl.PluralRules reference says the same thing in prose: English has four ordinal forms while Chinese and Arabic have one. The categories tell you which branch of a message to use. They do not tell you what text belongs in that branch. That is the translator's job.
Gender is the part suffix helpers cannot model
Grammatical agreement gets less attention. In French the first item is 1er for a masculine noun and 1re for a feminine one; CLDR's own example uses the feminine 1re because the noun is "la" (the turn). A Django user ran into exactly this in Is there support for ordinal number suffixes localization?, noting that the French ending depends on the gender of the word being counted. Spanish has the same split between 1.º and 1.ª, and the Italian example above shows the article changing with the number.
A shared formatOrdinal(n) helper therefore fails even when it is backed by correct CLDR categories. The category for 1 in French is always one, but the right text depends on whether the sentence is about a place, a step, a lap, or a person. The helper has no way to know.
An ordinal category alone cannot pick the right ending in gendered languages: French, Spanish, and Italian ordinals agree with the counted noun, so the ordinal must live in a full translatable message per noun, not in a shared formatOrdinal(n) helper. What to do differently: put the ordinal inside the message for each noun, so "You finished {rank, selectordinal, ...}" and "Step {step, selectordinal, ...} of {total}" are separate keys. The French translator can then write the masculine or feminine form in each one. If you reuse one generic ordinal string across nouns, you are guaranteeing a grammar error in at least one of them.
Languages with one ordinal form need a different sentence
Languages at the other end need a different fix. CLDR gives Japanese a single ordinal category, and MDN notes the same for Chinese and Arabic. A translator working in those languages does not need four branches; they need permission to write the sentence differently. In Japanese a ranking usually reads as 第3位 or simply 3位, a structure that puts the number between characters rather than before a suffix.
Japanese, Chinese, and Arabic have a single ordinal category, so the useful translation is usually a different sentence (such as 第3位 or a rank number) rather than a suffix; give translators a message they can restructure instead of a slot for a suffix. What to do differently: write source messages that describe the meaning, not the English shape, and add a translator note such as "rank in the final standings; restructure as needed." Avoid keys like ordinal_suffix_one that force translators to supply an ending. If a market prefers #3 or "position 3," that is a valid translation, and your message format should allow it. The Expensify report's suggestion to drop the ordinal day in Polish and Italian dates is the same idea applied to date formats.
Put ordinals in messages with selectordinal
ICU MessageFormat has a dedicated argument type for this. The FormatJS ICU syntax guide describes {key, selectordinal, matches} as choosing output from the ordinal rules of the current locale, notes that other is required, and explains that # inside a branch is formatted as a number. Android's android.icu.text.MessageFormat lists selectordinal as one of its complex argument types alongside plural and select.
An English source message might look like this:
finish_position = You finished {rank, selectordinal,
one {#st}
two {#nd}
few {#rd}
other {#th}
} out of {total, number} players.
A French translation does not need the two or few branches, and it can carry the agreement the noun needs:
finish_position = Vous avez terminé {rank, selectordinal,
one {#re}
other {#e}
} sur {total, number} joueuses.
The French message here assumes a feminine noun; a masculine message would use #er in the one branch. The translator makes the decision inside a full sentence, which is the principle behind our earlier guide on why not to concatenate strings.
Two rules keep this reliable. Pass the raw integer to the message, so the library formats # with the locale's digits and grouping. And make sure your translation tooling and validators accept every CLDR ordinal category for each target language, not just the English four, or Welsh translators will be blocked from writing valid branches.
Selecting categories directly on the web and Android
When you cannot use MessageFormat, select the category yourself and look up a complete string.
On the web, MDN's Intl.PluralRules() constructor documents the type option: "cardinal" is the default, and "ordinal" is for ranking or ordering, as in "1st," "2nd," and "3rd." The select() method returns one, two, few, or other for English ordinals. MDN's own example maps those tags to st, nd, rd, and th, which is fine for English and is exactly the step you should not generalize:
const rules = new Intl.PluralRules(appLocale, { type: "ordinal" });
function finishMessage(rank: number, total: number): string {
const category = rules.select(rank); // "one" | "two" | "few" | "many" | "zero" | "other"
return t(`finish_position.${category}`, { rank, total });
}
Here each translation file defines the categories its language uses, and each value is a full sentence. Build appLocale from the language the user chose in the app, not from the browser or device default, or a user who picked German on an English phone gets English ordinal rules.
On Android, android.icu.text.PluralRules has forLocale(Locale, PluralRules.PluralType) from API level 24, and PluralType.ORDINAL returns the ordinal rules. Android string resources only offer cardinal <plurals>, so a common pattern is to select the ordinal category with ICU and read a string resource named after it, or to keep the whole message in ICU format and format it with android.icu.text.MessageFormat. If you support devices below API 24, decide explicitly what those devices show rather than falling back to an English helper.
Standalone ordinal formatters and where they fit
Some platforms can produce an ordinal numeral directly. Apple documents NumberFormatter.Style.ordinal as "an ordinal style format," available since iOS 9. ICU's rule-based number format offers predefined SPELLOUT, ORDINAL, and DURATION rule sets per locale, and shows spelled-out ordinals such as "one hundred and thirty-fourth."
These are useful for labels where the ordinal stands alone, such as a podium badge, a table column of positions, or a step indicator with no sentence around it. They are not a substitute for messages. A formatter cannot know the gender of a noun it never sees, and inserting its output into a translated sentence brings back the concatenation problem. Set the formatter's locale from the app's selected language, and treat its output as one complete label.
A migration plan for an existing app
- Search the codebase for suffix helpers and literals:
"st","nd","rd","th",getOrdinalSuffix, date tokens such asdo, and string templates that append to a number. - List each place an ordinal appears and the noun it describes: rank, lap, step, floor, day of month, edition.
- Replace each with a full message per noun using
selectordinal, or category selection plus full strings where MessageFormat is not available. - Add translator notes describing the meaning and allowing restructuring.
- Update validators so every target language may supply exactly the ordinal categories CLDR defines for it.
- Decide per locale whether ordinal dates are worth keeping, and use the platform's localized date skeletons where they are not.
- Delete the English helper so it cannot creep back.
Tests that catch real ordinal bugs
Test the boundary numbers that each language's CLDR rule actually branches on (11 to 13 and 21 to 23 in English, 8, 11, 80, and 800 in Italian, 1 and 2 versus 11 and 12 in Swedish) instead of only 1, 2, 3, and 4. Testing 1, 2, 3, and 4 only exercises the easy branches. Use the numbers each language's rule actually branches on, taken from the CLDR chart:
- English: 1, 2, 3, 4, 11, 12, 13, 21, 22, 23, 101, 111.
- Italian: 7, 8, 11, 80, 800, checking that the
manybranch is used for 8, 11, 80, and 800. - Swedish: 1, 2, 3, 11, 12, 21, 22, checking that 11 and 12 fall into
other. - Welsh: 0, 1, 2, 3, 5, 7, 10, to touch all six categories.
- French: 1 and 2 for each noun, to confirm the gendered form in the
onebranch. - Japanese, Chinese, and Arabic: any number, checking that the message reads naturally and contains no Latin suffix.
Add a pseudo-locale check as well: if any visible string ends with st, nd, rd, or th directly after a digit in a non-English locale, a helper has leaked. Run the same tests after switching the in-app language without restarting, so stale PluralRules or formatter instances built for the previous language cannot hide.
Where this sits in your number formatting
Cardinal plurals, dates, and plain numbers are covered in our guide to localizing dates, times, and numbers. The same rules apply to ordinals: pass raw values, choose the locale from the app's selected language, and let locale data and translators decide the visible text.
Next action
Search your code for an ordinal suffix helper today. For each place it is used, write a message per noun with selectordinal, give translators a note that permits restructuring, and add the CLDR boundary numbers above to your tests.
