{"name":"make-plural","version":"8.0.0","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"Unicode-DFS-2016","_id":"make-plural@8.0.0","maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"homepage":"https://github.com/eemeli/make-plural#readme","bugs":{"url":"https://github.com/eemeli/make-plural/issues"},"dist":{"shasum":"18907d9b8d5ce97df36db1b038cffffe64e42743","tarball":"http://registry-npm.ywwl.com/make-plural/download/make-plural-8.0.0.tgz","fileCount":16,"integrity":"sha512-uIHnF+aZQ6L19BDhNbJfQgXvXsC4vGDavSeSXEQYXVAzTZSfTGBvHzLx45VQxIllG7uaSrmf3wu/lKlipAIiRA==","signatures":[{"sig":"MEYCIQCNyQH435ZERvXZRZdmnCNcbShoIYSxrnDjmHOk62mVGAIhAJJPsPBisdR803nJB5iROR4neyixs2d0VaJZxjLNBL/u","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":295514,"size":23648,"noattachment":false,"key":"/make-plural/-/make-plural-8.0.0.tgz"},"type":"module","exports":{".":"./plurals.js","./ranges":"./ranges.js","./plurals":"./plurals.js","./examples":"./examples.js","./ordinals":"./ordinals.js","./cardinals":"./cardinals.js","./package.json":"./package.json","./examples.json":"./examples.json","./pluralCategories":"./pluralCategories.js"},"gitHead":"0774ae5b76cdebc363c8100b6a2eecc4d3a0ed47","_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"repository":{"url":"git+https://github.com/eemeli/make-plural.git","type":"git","directory":"packages/plurals"},"_npmVersion":"11.7.0","description":"Unicode CLDR pluralization rules as JavaScript functions","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/make-plural_8.0.0_1766953140089_0.5738880516640759","host":"s3://npm-registry-packages-npm-production"},"readme":"# make-plural\n\n`make-plural` provides JavaScript functions determining the pluralization categories of the approximately 220 languages included in the [Unicode CLDR].\nIn addition to the more commonly considered cardinal plurals (e.g. one book, two books), it also support ordinal plurals (e.g. 1st book, 2nd book, etc).\nIt's used internally by the [intl-pluralrules] polyfill.\n\nThe categorization functions are pre-compiled, require no runtime dependencies, and should compress to about 2.5kB.\nThe ES modules are designed to work well with tree-shaking, allowing for further size savings.\nIn order to generate an even smaller file from a subset of all possible language or to otherwise customise the modules, use [make-plural-cli] or [make-plural-compiler].\n\n[intl-pluralrules]: https://www.npmjs.com/package/intl-pluralrules\n[unicode cldr]: http://cldr.unicode.org/\n[make-plural-cli]: https://www.npmjs.com/package/make-plural-cli\n[make-plural-compiler]: https://www.npmjs.com/package/make-plural-compiler\n\n## Installation & Usage\n\n```\nnpm install make-plural\n```\n\n```js\nimport * as Plurals from 'make-plural/plurals' // or just 'make-plural'\nimport * as Cardinals from 'make-plural/cardinals'\nimport * as Examples from 'make-plural/examples'\nimport * as Ordinals from 'make-plural/ordinals'\nimport * as Categories from 'make-plural/pluralCategories'\nimport * as PluralRanges from 'make-plural/ranges'\n```\n\nEach of the endpoints is available as ES modules only.\n- `Cardinals`, `Ordinals` and `Plurals` each export a set of functions keyed by locale code,\n  returning the pluralization category for the input (either a number or a string representation of a number).\n  `Plurals` functions also accept a second boolean parameter to return\n  the ordinal (`true`) rather than cardinal (`false`, default) plural category.\n  For some locales, an additional argument sets the exponent used in compact notation;\n  currently, this is only used in Romance languages.\n  Note that `Ordinals` includes a slightly smaller subset of locales than `Cardinals` and `Plurals`,\n  due to a lack of data in the CLDR.\n- `PluralRanges` provides a set of functions similarly keyed by locale code,\n  but returning the pliralization category of a numerical range,\n  given the corresponding categories of its start and end values as arguments.\n- `Categories` has a similar structure,\n  but contains for each language an array of the pluralization categories\n  the cardinal and ordinal rules that that language's pluralization function may output.\n- `Examples` provide sample numeric values for each language's categories.\n\nThe object keys are named using the corresponding 2-3 character [language code].\nDue to JavaScript identifier restrictions, there is one exception:\nPortugese as spoken in Portugal (`pt-PT`; `pt` is Brazilian Portuguese) is available as `pt_PT`.\nThe transformation used for locale names is available as [safe-identifier] on npm.\n\n[language]: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html\n[language code]: https://www.unicode.org/cldr/charts/latest/supplemental/languages_and_scripts.html\n[safe-identifier]: https://www.npmjs.com/package/safe-identifier\n\nTree shaking should be able drop all but the explicitly used functions from the output,\nprovided that **named rather than wildcard imports** are used.\n\n```js\nimport { en } from 'make-plural'\n\nen(1) // 'one'\nen('1.0') // 'other'\nen(2) // 'other'\nen(2, true) // 'two' (ordinal)\n\nString(en)\n// (n, ord) => {\n//   const s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2);\n//   if (ord) return n10 == 1 && n100 != 11 ? 'one'\n//     : n10 == 2 && n100 != 12 ? 'two'\n//     : n10 == 3 && n100 != 13 ? 'few'\n//     : 'other';\n//   return n == 1 && v0 ? 'one' : 'other';\n// }\n\nimport { en as ordinalEn } from 'make-plural/ordinals'\n\nordinalEn(3) // 'few'\n\nimport * as Categories from 'make-plural/pluralCategories'\n// { af: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },\n//   ak: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },\n//   am: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },\n//   ar:\n//    { cardinal: [ 'zero', 'one', 'two', 'few', 'many', 'other' ],\n//      ordinal: [ 'other' ] },\n// ...\n//   en: {\n//       cardinal: [ 'one', 'other' ],\n//       ordinal: [ 'one', 'two', 'few', 'other' ]\n//     },\n// ...\n//   zh: { cardinal: [ 'other' ], ordinal: [ 'other' ] },\n//   zu: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] } }\n\nimport { en as rangeEn, ro as rangeRo } from 'make-plural/ranges'\n\nString(rangeEn)\n// (start, end) => \"other\"\n\nString(rangeRo)\n// (start, end) => end === \"few\" ? \"few\" : end === \"one\" ? \"few\" : \"other\"\n```\n","publish_time":1766953140238,"_cnpm_publish_time":1766953140238,"dist-tags":{"latest":"8.2.0"}}