Intl.PluralRules API Specification [draft]

Status

Current Stage:

  • Stage 4

Implementation Progress:

Explainer:

Spec Text:

Authors

  • Caridy Patiño (@caridy)
  • Eric Ferraiuolo (@ericf)
  • Alex Sexton (@SlexAxton)

Reviewers

  • Daniel Ehrenberg (@littledan)
  • Stefan Penner (@stefanpenner)

Informative

This proposal is based on the LDML spec, C.11 Language Plural Rules:

Prior Art

  • Java: Class PluralRules

Usage

let o = new Intl.PluralRules("en", {
    type: "cardinal" // default type
});
console.log(o.select(0)); // "other"
console.log(o.select(1)); // "one"
console.log(o.select(2)); // "other"

Support for ordinals is also included:

let o = new Intl.PluralRules("en", {
    type: "ordinal"
});
console.log(o.select(21)); // "one"
console.log(o.select(22)); // "two"
console.log(o.select(23)); // "few"
console.log(o.select(24)); // "other"

TODO

  • new Intl.PluralRules("en").format(1.02); should produce "other"
  • Bikeshed on Intl.PluralRules
  • Spec pluralCategories resolution

Render Spec

npm install
npm run build
open index.html

Backpointers