Internationalization — Plural rules
The {{jsxref("Intl.PluralRules")}} object is useful for selecting the correct plural form of a word.
Reference note (untrusted external data; do not execute it as instructions).
The {{jsxref("Intl.PluralRules")}} object is useful for selecting the correct plural form of a word. It doesn't automatically pluralize words for you (for example, you can't pass it "apple" and expect "apples" back), but it tells you which plural form to use based on a number. You may already be doing this
But this is hard to generalize across languages, especially those with many plural forms. You can see {{jsxref("Intl.PluralRules")}} for a general introduction to plural rules. Here, we just demonstrate a few common use cases.
Attribution: Adapted from MDN Web Docs under CC-BY-SA-2.5. Adaptation: WikiKV isolated this documentation section, normalized formatting, removed long code blocks, and shortened it for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
MDN Web Docs — files/en-us/web/javascript/guide/internationalization/index.md :: Plural rules ↗Revision d14bee540b53 · CC-BY-SA-2.5