make-plural

Make-plural is a JavaScript module that translates Unicode CLDR pluralization
rules to JavaScript functions. It includes both a live parser as well as the
generated output for the latest edition of the CLDR; the latter is just over 2kB
in size when minified & gzipped and covers 199 languages, so it's probably what
you want unless you really know what you're doing.

Make-plural is written in ECMAScript 6 and transpiled using Babel and
Browserify to CommonJS and AMD and ES6 module formats, as well as being
suitable for use in browser environments.

Installation

Precompiled plurals

umd/plurals.js contains an UMD module that can be included with node's
require or AMD's define. In a browser environment, it will populate a global
object plurals. Said module contains 199 functions (one per language),
each taking as a first parameter the value to be classified (either a number or
a string), and as an optional second parameter, a boolean that if true, applies
ordinal rather than cardinal rules.

umd/pluralCategories.js has a similar structure to umd/plurals.js, but
contains an array of the pluralization categories the cardinal and ordinal rules
each language's pluralization function may output.

es6/plurals.js and es6/pluralCategories.js are the ES6 module equivalents of
the above.

If your language isn't directly included in either of the above, try removing
any trailing parts that are separated from the stem by - or _. Note also
that the capitalization of locale codes is lowercase for the language, but
uppercase for the country, so for example the code for Portugese as spoken in
Portugal is pt-PT.

ordinals — if true, rules for ordinal values (1st, 2nd, etc.) are included

If both cardinals and ordinals are true, the returned function takes a
second parameter ord. Then, if ord is true, the function will return the
ordinal rather than cardinal category applicable to n in locale lc.

If the second parameter is undefined, the values are taken from
MakePlural.cardinals (default true) and MakePlural.ordinals (default
false).