locale string required Unicode BCP 47 locale identifier. It is canonicalized, then explicitly checked against the runtime's plural-rule data; unsupported locales are a 400, never a silent default-locale fallback.
Select real cardinal or ordinal plural categories for a BCP 47 locale with runtime ECMA-402/CLDR rules and explicit locale validation.
Authoritative reference data or standards computation
| Parameter | Type | Default & allowed | Description |
|---|---|---|---|
locale
required
| string | allowed: 2 – 64 example: en-US | Unicode BCP 47 locale identifier. It is canonicalized, then explicitly checked against the runtime's plural-rule data; unsupported locales are a 400, never a silent default-locale fallback. |
type | enum | default: cardinal allowed: cardinal | ordinal example: ordinal | cardinal selects quantity forms (one item, two items); ordinal selects ordering forms (1st, 2nd, 3rd). |
value
required
| float | allowed: -1000000000000000 – 1000000000000000 example: 2 | Finite numeric operand to classify, between -10^15 and 10^15 inclusive. |
minimumFractionDigits | int | default: 0 allowed: 0 – 20 example: 0 | Minimum visible fraction digits used before plural selection. Must be no greater than maximumFractionDigits. |
maximumFractionDigits | int | default: 3 allowed: 0 – 20 example: 3 | Maximum fraction digits used to round the operand before plural selection (0–20). |
locale string required Unicode BCP 47 locale identifier. It is canonicalized, then explicitly checked against the runtime's plural-rule data; unsupported locales are a 400, never a silent default-locale fallback.
type enum cardinal selects quantity forms (one item, two items); ordinal selects ordering forms (1st, 2nd, 3rd).
value float required Finite numeric operand to classify, between -10^15 and 10^15 inclusive.
minimumFractionDigits int Minimum visible fraction digits used before plural selection. Must be no greater than maximumFractionDigits.
maximumFractionDigits int Maximum fraction digits used to round the operand before plural selection (0–20).
| Parameter | Type | Default & allowed | Description |
|---|---|---|---|
fields | list | example: value,locale | Return only these fields (comma-separated). Mutually exclusive with 'exclude'. |
exclude | list | example: maximumFractionDigits | Return all fields except these (comma-separated). |
pretty | boolean | default: false example: true | Pretty-print the JSON response. |
unwrap | boolean | default: false example: true | Drop the envelope: return the raw array/object without data/meta wrapper. |
fields list Return only these fields (comma-separated). Mutually exclusive with 'exclude'.
exclude list Return all fields except these (comma-separated).
pretty boolean Pretty-print the JSON response.
unwrap boolean Drop the envelope: return the raw array/object without data/meta wrapper.
| Field | Type | Description | Example |
|---|---|---|---|
value | float | Numeric operand supplied by the caller. | 2 |
locale | string | Actual locale resolved by Intl.PluralRules. | en-US |
type | string | cardinal or ordinal rule family. | ordinal |
category | string | Selected ECMA-402 plural category. | two |
categories | string[] | All categories available for this resolved locale/type. | ["one","two","few","other"] |
minimumFractionDigits | integer | Resolved minimum fraction digits used during selection. | 0 |
maximumFractionDigits | integer | Resolved maximum fraction digits used during selection. | 3 |
value float Numeric operand supplied by the caller.
example: 2
locale string Actual locale resolved by Intl.PluralRules.
example: en-US
type string cardinal or ordinal rule family.
example: ordinal
category string Selected ECMA-402 plural category.
example: two
categories string[] All categories available for this resolved locale/type.
example: ["one","two","few","other"]
minimumFractionDigits integer Resolved minimum fraction digits used during selection.
example: 0
maximumFractionDigits integer Resolved maximum fraction digits used during selection.
example: 3
/api/plural-rules/select?locale=en-US&type=ordinal&value=2 {
"data": {
"value": 2,
"locale": "en",
"type": "ordinal",
"category": "two",
"categories": [
"few",
"one",
"two",
"other"
],
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"meta": {
"endpoint": "plural-rules",
"route": "/select",
"params": {
"locale": "en-US",
"type": "ordinal",
"value": 2,
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} /api/plural-rules/select?locale=ar&type=cardinal&value=2 {
"data": {
"value": 2,
"locale": "ar",
"type": "cardinal",
"category": "two",
"categories": [
"few",
"many",
"one",
"two",
"zero",
"other"
],
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"meta": {
"endpoint": "plural-rules",
"route": "/select",
"params": {
"locale": "ar",
"type": "cardinal",
"value": 2,
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} /api/plural-rules/select?locale=ru&value=5 {
"data": {
"value": 5,
"locale": "ru",
"type": "cardinal",
"category": "many",
"categories": [
"few",
"many",
"one",
"other"
],
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"meta": {
"endpoint": "plural-rules",
"route": "/select",
"params": {
"locale": "ru",
"type": "cardinal",
"value": 5,
"minimumFractionDigits": 0,
"maximumFractionDigits": 3
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} Returns the runtime locale/type vocabulary. Fraction-digit options are intentionally /select-only because ECMA-402 pluralCategories is not narrowed by them.
| Parameter | Type | Default & allowed | Description |
|---|---|---|---|
locale
required
| string | allowed: 2 – 64 example: en-US | Unicode BCP 47 locale identifier. It is canonicalized, then explicitly checked against the runtime's plural-rule data; unsupported locales are a 400, never a silent default-locale fallback. |
type | enum | default: cardinal allowed: cardinal | ordinal example: ordinal | cardinal selects quantity forms (one item, two items); ordinal selects ordering forms (1st, 2nd, 3rd). |
locale string required Unicode BCP 47 locale identifier. It is canonicalized, then explicitly checked against the runtime's plural-rule data; unsupported locales are a 400, never a silent default-locale fallback.
type enum cardinal selects quantity forms (one item, two items); ordinal selects ordering forms (1st, 2nd, 3rd).
| Parameter | Type | Default & allowed | Description |
|---|---|---|---|
fields | list | example: locale,type | Return only these fields (comma-separated). Mutually exclusive with 'exclude'. |
exclude | list | example: categories | Return all fields except these (comma-separated). |
pretty | boolean | default: false example: true | Pretty-print the JSON response. |
unwrap | boolean | default: false example: true | Drop the envelope: return the raw array/object without data/meta wrapper. |
fields list Return only these fields (comma-separated). Mutually exclusive with 'exclude'.
exclude list Return all fields except these (comma-separated).
pretty boolean Pretty-print the JSON response.
unwrap boolean Drop the envelope: return the raw array/object without data/meta wrapper.
| Field | Type | Description | Example |
|---|---|---|---|
locale | string | Actual locale resolved by Intl.PluralRules. | ru |
type | string | cardinal or ordinal rule family. | cardinal |
categories | string[] | The complete category vocabulary exposed by the runtime for this locale/type. | ["one","few","many","other"] |
locale string Actual locale resolved by Intl.PluralRules.
example: ru
type string cardinal or ordinal rule family.
example: cardinal
categories string[] The complete category vocabulary exposed by the runtime for this locale/type.
example: ["one","few","many","other"]
/api/plural-rules/categories?locale=ru&type=cardinal {
"data": {
"locale": "ru",
"type": "cardinal",
"categories": [
"few",
"many",
"one",
"other"
]
},
"meta": {
"endpoint": "plural-rules",
"route": "/categories",
"params": {
"locale": "ru",
"type": "cardinal"
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} /api/plural-rules/categories?locale=en&type=ordinal {
"data": {
"locale": "en",
"type": "ordinal",
"categories": [
"few",
"one",
"two",
"other"
]
},
"meta": {
"endpoint": "plural-rules",
"route": "/categories",
"params": {
"locale": "en",
"type": "ordinal"
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} /api/plural-rules/categories?locale=da-DK&type=cardinal {
"data": {
"locale": "da",
"type": "cardinal",
"categories": [
"one",
"other"
]
},
"meta": {
"endpoint": "plural-rules",
"route": "/categories",
"params": {
"locale": "da-DK",
"type": "cardinal"
},
"generatedAt": "2026-07-29T08:13:22.000Z"
}
} Locale-aware plural selection using the runtime's standards-based Intl.PluralRules implementation. It answers which translation branch a numeric value belongs to — zero, one, two, few, many or other — without reducing every language to an English singular/plural assumption.
/select accepts one finite number, a BCP 47 locale and type=cardinal|ordinal. Fraction-digit options are passed to ECMA-402 before selection, because rounding and visible decimals can change the chosen category./categories returns the runtime's category vocabulary for the resolved locale/type, in the order exposed by resolvedOptions().pluralCategories. Fraction-digit options belong only to /select: ECMA-402 does not narrow pluralCategories to categories reachable under one rounding configuration, so this route deliberately does not accept them.Locale handling is deliberately strict. The input is canonicalized with Intl.getCanonicalLocales, checked with Intl.PluralRules.supportedLocalesOf, and echoed in canonical form. An unsupported locale returns a 400 instead of silently falling back to the Worker's default locale. The response also exposes the actual resolved locale, because a supported regional tag may intentionally use its parent language's plural data.
The rules come from the runtime's ICU/CLDR data and can improve with runtime upgrades. This endpoint chooses grammatical categories only; it does not translate nouns or sentences.
The ECMA-402 categories are zero, one, two, few, many and other; each locale exposes only the categories its cardinal or ordinal rules actually use.
No. The locale is canonicalized and checked against runtime plural data first; unsupported values answer 400 rather than silently returning a different language's rule.
Plural operands are evaluated after ECMA-402 number rounding. minimumFractionDigits and maximumFractionDigits make that visible behavior explicit and reproducible.
All 183 active ISO 639 two-letter language codes with matching terminology and bibliographic three-letter codes, searchable with exact lookups.
Canonicalize BCP 47 language tags and run RFC 4647 lookup or basic filtering with bounded, deterministic matching.
Inspect UTF-16 and Unicode scalar values, apply the four standard normalization forms, and segment text into graphemes, words or sentences.
Random integers or floats in any range — control decimal precision, draw guaranteed-unique values, and pin a seed for reproducible sequences.
Random English words by part of speech — nouns, verbs, adjectives or adverbs — with working length filters, seedable output and honest 400s when nothing fits.
Sort and compare strings the way a locale actually orders them: German sorts ä with a, Swedish sorts it after z. Every option visibly changes the answer.