Skip to content
Novus Examples
json1.5 KB

ICU selectordinal — English ordinal suffixes

English st/nd/rd/th suffixes done properly, via ICU selectordinal rather than a hand-written switch. The case list covers the teens (11th, 12th, 13th) and the wrap-around (21st, 102nd, 111th) that a naive n % 10 lookup gets wrong.

Preview — first 50 linesjson
{
  "locale": "en",
  "format": "icu-messageformat",
  "note": "In ICU MessageFormat, '#' inside a plural branch binds to the NEAREST enclosing plural argument, not the outermost one. Where an outer count must appear inside an inner plural, these messages use the explicit {name} form instead of '#'.",
  "messages": {
    "place": "You finished {n, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}",
    "floor": "Take the lift to the {n, selectordinal, one {#st} two {#nd} few {#rd} other {#th}} floor"
  },
  "cases": [
    {
      "n": 1,
      "category": "one",
      "expected": "You finished 1st"
    },
    {
      "n": 2,
      "category": "two",
      "expected": "You finished 2nd"
    },
    {
      "n": 3,
      "category": "few",
      "expected": "You finished 3rd"
    },
    {
      "n": 4,
      "category": "other",
      "expected": "You finished 4th"
    },
    {
      "n": 11,
      "category": "other",
      "expected": "You finished 11th"
    },
    {
      "n": 12,
      "category": "other",
      "expected": "You finished 12th"
    },
    {
      "n": 13,
      "category": "other",
      "expected": "You finished 13th"
    },
    {
      "n": 21,
      "category": "one",
      "expected": "You finished 21st"
    },
    {
63 lines total — download for the full file.

Specifications

Format
ICU MessageFormat
Locale
en
Feature
selectordinal
Ordinal Categories
one, two, few, other
Cases
10
Seed
20260807
Wave
p7
Line Endings
LF

Testing contract

Expected to pass
Scenario
Format the `place` message for each n in the case list.
Expected result
1st, 2nd, 3rd, 4th, 11th, 12th, 13th, 21st, 102nd and 111th — in particular 11, 12 and 13 take 'th' while 21, 102 take 'st' and 'nd'.

What is a .json file?

JSON (JavaScript Object Notation) is a lightweight, text-based data-interchange format representing objects, arrays, strings, numbers, booleans, and null. It is language-independent, human-readable, and the dominant format for web APIs and configuration. It requires a single well-formed root value.

How to use this file

Use an example JSON file to test parsers and serializers, schema validation, Unicode and number-precision handling, and API request or response processing.

How to use this file for testing

“ICU selectordinal — English ordinal suffixes” is a deterministic Novus Examples fixture for Internationalization, Localization catalogs, JSON parsing. Parallel text and accented, multi-script content — for testing translation pipelines, Unicode handling, and localization tooling.

Documented properties for this file: seed 20260807 · LF · ICU MessageFormat. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Translation-catalog fixtures carry the same message set across formats, each with its native placeholder syntax. Test your i18n loader, catalog converter, or translation-memory tool, and use the RTL and CJK variants to check bidirectional text and Unicode handling.

Load the catalog with your i18n framework and verify placeholder interpolation and plural handling; the RTL and CJK variants exercise bidirectional text and font fallback.

Code examples

import json

with open("selectordinal-en.json") as f:
    data = json.load(f)
print(type(data), len(data))

Generated by generation/localization_p7.py. Free for any use, no attribution required — license.