Package Exports
- @boxid/plurals-cldr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@boxid/plurals-cldr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
plurals-cldr - plurals support for JS
Key benefits:
- Competely automated code generation from CLDR on update.
- Generated code automatically tested with CLDR fixtures.
- Both
cardinalandordinalforms support. - Rules for all languages are stored in single file in very compact form.
Installation
node.js:
$ npm install plurals-cldrbrowser:
$ bower install plurals-cldrRebuild
make clean
make generateAPI
.(locale, number)
Returns 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'.forms(locale)
Returns array of available forms for specified locale. If locale not supported,
returns null.
.indexOf(locale, number)
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.
.ordinal(), .ordinal.forms(), ordinal.indexOf()
The same as above, but for ordinal forms.
References
License
Mit.