package
Plurals support, generated from CLDR.
npm install plurals-cldrGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
51.3 kB
Includes dependencies.
Key benefits:
cardinal and ordinal forms support.node.js:
$ npm install plurals-cldrReturns form name for given number. Number can be passed as string to keep
tailing decimal zeros. If locale not supported, returns null.
var plural = require('plural-cldr');
// Get cardinal form name
//
// Params:
//
// - locale
// - number (Number|String)
//
plural('ru', 0) // -> 'many'
plural('ru', 1) // -> 'one'
plural('ru', 2) // -> 'few'
plural('ru', 19) // -> 'many'
plural('ru', 0.5) // -> 'other'Returns array of available forms for specified locale. If locale not supported,
returns null.
Returns index of form for specified locale. That's convenient, if you wish to implement lookup from compact ordered list, like babelfish does.
If locale not supported, function returns -1.
Order of forms is the same for all languages: zero, one, two, few,
many, other. Remove unavailable forms, and you will get indexes of each.
The same as above, but for ordinal forms.
You need to bump cldr-core version & run rebuild:
npm install cldr-core@latest --save-dev
rm package-lock.json
rm -rf node_modules
npm install
npm run build