Dev Helpers

Node.js / Internationalization

Select an ordinal suffix category

Dev Helpers · August 16, 2025

Ordinal categories vary by locale. Use the category as an input to a localized suffix table instead of attaching an English ending everywhere.

Worked example

const date = new Date("2026-01-02T13:30:00Z");
console.log(new Intl.PluralRules("en", { type: "ordinal" }).select(22));

Result

two

Implementation notes

A plural category is not the final formatted ordinal. Each supported language needs an appropriate mapping or a formatter that supplies the full display value.

Try it yourself

Compare 1, 2, 3, 11 and 21 in the target locale.

Open the Node.js example →

Editorial date August 16, 2025 · Published December 6, 2026

Related articles

Safely parse malformed input

Parsing user-provided JSON needs a failure path. Successful parsing alone does not establish that the result has the expected shape.

Checksum bytes with CRC32

CRC32 is useful for detecting accidental changes to a byte sequence. Record the input encoding so different producers compute the same checksum.

Attach details to a mark

Performance marks can carry details about the operation they describe. Small stable identifiers are easier to aggregate than large payloads.