{"name":"make-plural","version":"6.0.0-beta.1","description":"Unicode CLDR pluralization rules as JavaScript functions","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","homepage":"https://github.com/eemeli/make-plural#readme","repository":{"type":"git","url":"git+https://github.com/eemeli/make-plural.git","directory":"packages/plurals"},"bugs":{"url":"https://github.com/eemeli/make-plural/issues"},"main":"plurals","module":"plurals.mjs","sideEffects":false,"scripts":{"build":"npm run mjs && npm run umd","mjs":"npm run mjs:plurals && npm run mjs:plural-categories","mjs:plurals":"../cli/make-plural plurals -w118 > plurals.mjs","mjs:plural-categories":"../cli/make-plural categories > pluralCategories.mjs","umd":"npm run umd:plurals && npm run umd:plural-categories","umd:plurals":"../cli/make-plural plurals --umd -w118 > plurals.js","umd:plural-categories":"../cli/make-plural categories --umd > pluralCategories.js"},"gitHead":"3cc6b3ff7d03aebefc287c974905dfe430b66e75","readme":"# make-plural\n\n`make-plural` provides JavaScript functions determining the pluralization categories of the approximately 200 languages included in the [Unicode CLDR]. In 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). It'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. The ES module exports in particular are designed to work well with tree-shaking, allowing for further size savings. In order to generate an even smaller file from a subset of all possible language (or to drop ordinal plural support), 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\nThe package's \"main\" export provides approximately 200 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. In Webpack, Rollup, and other environments that support it, this will resolve to `plurals.mjs`, an ES6 module. Elsewhere, this will resolve to `plurals.js`, an UMD module.\n\n`make-plural/pluralCategories` has a similar structure to the main export `make-plural/plurals`, but contains for each language an array of the pluralization categories the cardinal and ordinal rules that that language's pluralization function may output. It is also provided in `.mjs` and `.js` variants.\n\nThe pluralization functions are almost all named using the corresponding 2-3 character [language code]. Due to JavaScript identifier restrictions, there are two exceptions: the function for Portugese as spoken in Portugal (`pt-PT`; `pt` is Brazilian Portuguese) is available as `pt_PT()`, and the now-deprecated `in` subtag for Indonesian (preferred: `id`) is available as `_in()`. The exact `identifier()` transformation used for these names is available from [safe-identifier] package 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\n```js\nimport { en } from 'make-plural'\n\nen(1) // 'one'\nen(2) // 'other'\nen(2, true) // 'two' (ordinal)\n\nString(en)\n// function en(n, ord) {\n//   var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n,\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 * as categories from 'make-plural/pluralCategories'\n// { _in: { cardinal: [ 'other' ], ordinal: [ 'other' ] },\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```\n\n## Optimization and Tree Shaking\n\nThe package file paths and exports are structured in a manner that should allow transparent usage in any module system. In particular, when importing as an ES6 module, tree shaking should be able drop all but the explicitly used functions from the output, provided that named rather than wildcard imports are used.\n","readmeFilename":"README.md","_id":"make-plural@6.0.0-beta.1","_nodeVersion":"12.6.0","_npmVersion":"lerna/3.16.4/node@v12.6.0+x64 (darwin)","dist":{"integrity":"sha512-2iyInU/Ev3LMU0JQLhkUXjyKv2freZ1lW6YqtsEKLX3FXkFSV9kJMNV7C3bztRNRJZd3ePx6ikSYqrspXs+SOw==","shasum":"1bf8a73d27e06f775b015a6c9d300bfecdfd335a","tarball":"http://registry-npm.ywwl.com/make-plural/download/make-plural-6.0.0-beta.1.tgz","fileCount":8,"unpackedSize":63195,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZj3SCRA9TVsSAnZWagAAr0YP/jYTT+IgQ56aS/Ov4ftH\nwgfNu0LhVVp3QxzYkhHJaJv+ymya7a6Z9hOqt4Y7MwXfYsyYKSZKcWX7FEV1\nqwGAljU3wQEbUKsX2d+JsiEw6rEDz0ACUqBCSXkD64/n+ufnnSWoCwrVgfmv\nyY4HTSMNY8fsT1NjvHtcAYrgYZo3zkQLfpX5z2cPlv0qUCJkeacTcb4u1NQI\nfDwHO1XaTPb8mtADVXDhgk1vKvndAHPU1d/rUOYoquQsaajYhEqbLAEQ/SPk\nPP0fT73cVKWDfmc5h4sleJvLZHXpXHoZdqaRptKHVaqjmd7DG7Y7DTlGRXPb\n3cgBNDyqD0Awpz+rxTGuxG8u01Qk//gzVj6nRLj+VkCiYCEz35oS7gSqFAa4\nqv5g/WzE4jFDvhqgfqXSwTzapPVTke3MmRel7Gi3VtCHr9RRu/glZ58qWT8C\nEBu0vqoOlYRguJHzFFnutexD7/TU4AYBBsEsfVoQdZBboulVsS4Bj8HRMaZb\ntWOettBKcDfQQfiC5uTznx53tf+T8bUNfLVbKe5IYZgtuEu+B0xMFTDjkD7r\nJlfa/nxqDUdEobbjyj/6GnhSSQ96N5Wts6ZRDjl7FFEzAzyORz2v7qGwpP5e\nVL/SRZKxDQjuY7WdthQ4jzNxcdBuxlgwtfnJgTTUEDT3njCC1/0lZy5Xua50\neAwT\r\n=oGCt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDORDmteXkJUfKQUInwoCHiiz182YELG2G3jONRsrOhsgIhANZ7wjhHUG3NPgreyt6mFEe3+zduXXzq28jVMjKHCzrE"}],"size":10090,"noattachment":false,"key":"/make-plural/-/make-plural-6.0.0-beta.1.tgz"},"maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/make-plural_6.0.0-beta.1_1566981586182_0.9932222034887217"},"_hasShrinkwrap":false,"publish_time":1566981586341,"_cnpm_publish_time":1566981586341,"dist-tags":{"latest":"8.2.0"}}