{"_id":"make-plural-compiler","_rev":"7-a88f42c066fba0f6463f4ddacbc89899","name":"make-plural-compiler","dist-tags":{"latest":"6.1.0"},"versions":{"5.0.0-beta.1":{"name":"make-plural-compiler","version":"5.0.0-beta.1","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","_id":"make-plural-compiler@5.0.0-beta.1","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":"a8cc69826e87a3bc9bf949137e4052f23f5af84b","tarball":"https://registry.npmjs.org/make-plural-compiler/-/make-plural-compiler-5.0.0-beta.1.tgz","fileCount":8,"integrity":"sha512-Ai1/BRXDspGbnFTIm1zkU97zudbaly9AZYH0fkhrGIUc52SNPTy/98MQ5pLYPxOaOYTZpEq82Xwn6f0jiNvbYA==","signatures":[{"sig":"MEUCIQCdrFuNh/qWHhLvk+3xyklD/Utbi/kNWfPu8KI2EBLiXAIgFAzUUfntAF9yjKtw/Ufz+9uTT8PCozoQBXWncvwpT3k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14440,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdA8C1CRA9TVsSAnZWagAAI88QAJCd7j9q8g61nsv5shUL\nU987PYa53M2Im5ofRsBacUWLytiU0N2qEcnJc3MBBIXD6ao+pRIVfmAz/WBM\n5MHqbl8XjUuVfyUlOqfZaVAAWZWQtyT6NmdwcZT7ftmf35QsEK9HlSGcAt8j\nki/KJb96JQQ7byR/D6Usafc2nP0QYQKjfrkQgU2S3v1Lc0ohaIylng2T/rUW\nH4BV0sSHn4OnJU9Zm3Has3atGKKLdT9xJ22TeUdI65siWDXvd2KKf541fPKf\nATEKI9iyyJenqT7yOBccFtjgB7cX57fHZ2EskFqsnjnmxiHsaLZRvYFHvGHr\nrGEAAFMFscuifh8cJZHx3l0kE3RDb69MXxsJMtTnmSKrX6EmcrVu1qtzO/Md\nvM3xFZ+TVVUr1+Q3puH0G24HKob81Pq0Si9vuEGHSVyO7rWLvSvaemB0a894\nDXVdQ7x5tT0/35Ldj705JL6Foa1SH6KysQfDEn3MahBbl2ExY4yCyY4aufLf\n5c+jyQZolX9DXnkLnGHYOmxYsOa/pMoeJSFEeAz0oqrcKsVMXi3A+PlJNrCo\nE9zVp5v9AfeOmPXKHsG/QqPnbwDuQAnMcp+GRmu/dsuzTaShgqZTc6YMQEnB\nv1Nj3A1+Kox4tGv0eDW6FNx5gRO8pjVklBtn5XyUAXjbaIKtkPP//1lvIEzk\nsikA\r\n=c09l\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"c477307d684359d5ede3071c0c2a2dddc351c60a","_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"repository":{"url":"git+https://github.com/eemeli/make-plural.git","type":"git","directory":"packages/compiler"},"_npmVersion":"lerna/3.15.0/node@v11.9.0+x64 (darwin)","description":"Translates Unicode CLDR pluralization rules to executable JavaScript","directories":{},"_nodeVersion":"11.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/make-plural-compiler_5.0.0-beta.1_1560527029287_0.11554319481414588","host":"s3://npm-registry-packages"}},"5.0.0":{"name":"make-plural-compiler","version":"5.0.0","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","_id":"make-plural-compiler@5.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":"c189823cf724cdca27f2387520d9ba5bd2bb734a","tarball":"https://registry.npmjs.org/make-plural-compiler/-/make-plural-compiler-5.0.0.tgz","fileCount":7,"integrity":"sha512-nPK/DVoTIyh1QTWOT5NKRA9BvMZ2Fgoz+LxPT86srW7j+8D646yRJPVOiJO86XMUzjbsFccB6WXHG3eX1A+97Q==","signatures":[{"sig":"MEYCIQCY3mq3BFv8iNUnB+1YlPyIjkCBTMFM7xbXlRQtHLxQUwIhALz7bB/G3bDxTA17elO8qGALvkGvF1OP62Xj7aT6VEhM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14826,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLHu2CRA9TVsSAnZWagAAkTgP+QFXJn2CikmzB6/Uo0zu\nXRncqrY7qOi4Xjy4DcnAE+ixK0rLTHCUMpP8D7sWzY+2RNbjFLmk6up7AFig\nu7wWcTS7YSXe/Vx3NmNIOGhRbiqsWk5Oy0PnCw7F1hwzM1xsrNMF6OCzn+Vw\nlCsBvg+Nm0RUNqf+m6geIKZ5oA0hsjdfCMacRE5c8oYTUZUIQsDJqMqKbVe4\nkVT/TKxO0F787KO3ohklCXBJNG4QYGRXhDW68/yZYz0St0XIjfhqLlNf9F+c\nle9/Ci5dEDNwlPQYr8/YMq9W/o6Wvgx6V7cMrsXqX+3mnRm2JWubm+r6/Rc1\nZv7Uj4HH5QxqVvwcKoyI7YBwKXF7bC7UCS2EZwyrzqzYTxxnCQg3YKesAtRa\nZUWY7+0pET0k6cZb+EtR+G0DRFApQc6zYiu0hGzNSHbEBZMb7ne+lWmfRQvP\nNhqOWgYKRsPtX3sMEhbn8/0Fl/+YHmb9INHk+OO9f9XMKQsIfeDtp62CmfsP\nku/JgfGQGGtKZytzVYYQqRWka6JBGtko1ocasQccrau4s8uAGZFH/9rDflYT\nYO6TsSMGJ2Kh3vLTc+7iarEcXc4k8SY7iWx1iYNOXXTBCTVrOjfQYZVf29S8\nSNYR8R1NuGe+YUMPVVMF8SEBgO/rU/xXepXfhwB6/qr9d4ZKXYRoKKLm19T/\n4wr0\r\n=bIp5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"repository":{"url":"git+https://github.com/eemeli/make-plural.git","type":"git","directory":"packages/compiler"},"_npmVersion":"6.9.0","description":"Translates Unicode CLDR pluralization rules to executable JavaScript","directories":{},"_nodeVersion":"11.9.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/make-plural-compiler_5.0.0_1563196341339_0.5579294651500162","host":"s3://npm-registry-packages"}},"5.1.0":{"name":"make-plural-compiler","version":"5.1.0","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","_id":"make-plural-compiler@5.1.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":"3f5a96b44bfb0e343c38ed56b5e769801df6bae7","tarball":"https://registry.npmjs.org/make-plural-compiler/-/make-plural-compiler-5.1.0.tgz","fileCount":8,"integrity":"sha512-xOaWUIcU9K9ptuz1rjFKeLTvktddv7H/kCr4LpQYaO2TLkDjgSUj8soh4PX3CFVLziajY4wxepiZqVPyvXBrnA==","signatures":[{"sig":"MEYCIQDvQg2gKU5cOk14GRILa8RO5iHr7uVshPhFRV5sdkZKwQIhAJcyU8o4RDZ8LnjeR/fMhiEa7HuIFQJekgLwn8fydlcW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15841,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZMGpCRA9TVsSAnZWagAApRYQAIXXYCpaQfCEyzQ6Xq4T\nVzoLineWm8lWaAOlq0sHc9N0rtmNjy9khETDjHZ8uY0jvDi5yG3/99qRiNQa\npyI+p7l+JCM/Uc1viuqSJikWFg4Xsr5Lg7xvqPomSl23NoclVOwgU1cgyJfP\nLlLtGfO9YDFR8d5ZV7okc5cFa71nVnjsqc4ktRDSkekpgI6J+0GgyFrhOz7y\nIhVsWclUGFTueet6vgZ6fqkoWq5g/kYGuTNXaMiUUUExxIKx1agjfUiTnFWZ\nHHOZ9Cc0dk1yG+30WlUwKeEF3+aB+uEp218ElAsfP42S/oJwdiveyT+mXmn+\n6qIwdsPS6l+wvYAUBLtoj2jUMLBlibXCFmrUUhk3k2s7fmVbTEpI6ueO+m2V\nncbF1mUzJrDTYohJrU6KDI3cK1jJQqS3Yh5mVs7oGTanxNtrgQ2gIVaVIekv\nowxfq1VUebkmEqjVHYA/G8mbZCVdOShfMnOCr41Sw7aPmuRxzk7LTZaAGlOn\nZJogJ6nb2ze3mvCUIXmTUIoFFbSz6bPx1ZazmwNjI22Fuf+p6Uqzwldo8fyS\nsvl+TGXqDxpbs2GaNbDfHRZd0YrIK084jtV3DnuGzlhEbGx/o28+kFMmW+EQ\nB9CfR/t0SoondkE4JtfH4n1xeg4kwWkqnOHflHuJYgGPGvC3ShdqJRIVA+qP\ncYQI\r\n=m1Bl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"c8cc6a4282bcecbc3fb32a5dfb7a595ae256fdce","_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"repository":{"url":"git+https://github.com/eemeli/make-plural.git","type":"git","directory":"packages/compiler"},"_npmVersion":"lerna/3.20.2/node@v13.10.1+x64 (darwin)","description":"Translates Unicode CLDR pluralization rules to executable JavaScript","directories":{},"_nodeVersion":"13.10.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/make-plural-compiler_5.1.0_1583661481158_0.2009886757669097","host":"s3://npm-registry-packages"}},"6.0.0":{"name":"make-plural-compiler","version":"6.0.0","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","_id":"make-plural-compiler@6.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":"72c2ad3ffe36fd4d90cd16bcf93c6f3f9dca4058","tarball":"https://registry.npmjs.org/make-plural-compiler/-/make-plural-compiler-6.0.0.tgz","fileCount":7,"integrity":"sha512-fHM/j7NQeIizYtTAEUxGaR0blq8pLZTfdRU9XfLAM8/ysJFqg/3Hc/gNgxZ0Ck5j9TDz1CBEMBQWMMCQkNcO8w==","signatures":[{"sig":"MEUCIQCnUt910x7da9SL9I9H7+fTyHcP0wCDDsMDyB/CRo4+xAIgX8G30KJxwaQVyPbDIzhgmhkq/0kTPTTgyPLRUVXXLn0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhKI98CRA9TVsSAnZWagAAueQP/icz0gnPFETPiMwRVRzk\nqQhw6unmwSomMHOGk915LB9Ew6SSwRcTEdo6kvq6kgvw07UWwgmi+wYGVnio\n+QPGDge+0TVqDzMH4JBi5r0v6k0hhiW2TV847chtRJ5Cmrr1FzwE46qJa+sf\niVB3S9aeWAM35RfyLjafHkx3Z4jv3FF8e7Wiz4uEY3MCfcDGh433D1Xc9AyT\nieogT2sDqmz3ozZ42H9gIKzm2GbOjIgFO7X+9VJUcH5hMCRunwOeSq004R2m\nZxUkaXwa/DBLgK8P/50E1V9e6AJzD+OTGICWtkHjiWREqt1YKtdLBlgu03mX\n39aU4WW7/D4UBZQDLjlXoVV6wqQoXjft9lR0OSLKCOMqI6Hai8MPVFBG8Ghp\nWNLyWn67Y0uh2B9ZAeuZn3RZVn1LogirZzfwfCFDKKMm0/xMIyEo4CdgjL2m\nXktb302rIBxmpud3v8dLkj84yr6n99Y3r3SRzm9pCH9++gIVyfRHihcbWRS9\nkS9ebi9MHjiNDbRNRcXM/Q5errGQLbZTG0CiE7Iv8uQCt7burgij9FKQsA6X\nk9jNbgJkkeMMqxtvXlihQpGN/RHWEdQ3okgfbqpWyRhnNQBsDwnB54QB8URP\nP/lTMeVdGUigLPGslagcmk2hEBY8TBssMirFfwQ+lLz+fP7dCvxTbczhkBZT\nL8HP\r\n=gRYQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"repository":{"url":"git+https://github.com/eemeli/make-plural.git","type":"git","directory":"packages/compiler"},"_npmVersion":"7.20.3","description":"Translates Unicode CLDR pluralization rules to executable JavaScript","directories":{},"_nodeVersion":"16.6.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/make-plural-compiler_6.0.0_1630048124330_0.4655014481113653","host":"s3://npm-registry-packages"}},"6.1.0":{"name":"make-plural-compiler","version":"6.1.0","description":"Translates Unicode CLDR pluralization rules to executable JavaScript","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/compiler"},"bugs":{"url":"https://github.com/eemeli/make-plural/issues"},"main":"index.js","gitHead":"7b4c457054e8fa393bd8a5d891d247973dab6334","_id":"make-plural-compiler@6.1.0","_nodeVersion":"25.2.1","_npmVersion":"11.7.0","dist":{"integrity":"sha512-AhvPJA7VsN0xqfqxbabgJgXSARD+IDm0Mx53vawbknRDQ1bWE331fW9yQx1jPmdAXT3zGTJEUfPtwth8NreMFw==","shasum":"4482ffbab7d68732e77afbdcbc2cb237c004d4db","tarball":"https://registry.npmjs.org/make-plural-compiler/-/make-plural-compiler-6.1.0.tgz","fileCount":7,"unpackedSize":17095,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICUu1HbLL9Q1FnG+81FVZrd9y2NJRgYmToizl4H+mOjVAiBSDjfQfIYHQyX6zw80BsDNfhwsWqQB1mn4YZCrgPmI+Q=="}]},"_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"directories":{},"maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/make-plural-compiler_6.1.0_1766972890732_0.30974141126863763"},"_hasShrinkwrap":false}},"time":{"created":"2019-06-14T15:43:49.260Z","modified":"2025-12-29T01:48:11.374Z","5.0.0-beta.1":"2019-06-14T15:43:49.437Z","5.0.0":"2019-07-15T13:12:21.441Z","5.1.0":"2020-03-08T09:58:01.284Z","6.0.0":"2021-08-27T07:08:44.466Z","6.1.0":"2025-12-29T01:48:10.857Z"},"bugs":{"url":"https://github.com/eemeli/make-plural/issues"},"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","homepage":"https://github.com/eemeli/make-plural#readme","keywords":["unicode","cldr","i18n","internationalization","pluralization"],"repository":{"type":"git","url":"git+https://github.com/eemeli/make-plural.git","directory":"packages/compiler"},"description":"Translates Unicode CLDR pluralization rules to executable JavaScript","maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"readme":"# make-plural-compiler\n\n`make-plural-compiler` translates [Unicode CLDR] pluralization [rules] to JavaScript functions.\nA precompiled build of its output is published separately as the [make-plural] package.\n\n[unicode cldr]: http://cldr.unicode.org/\n[rules]: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html\n[make-plural]: https://www.npmjs.com/package/make-plural\n\n## Installation & Usage\n\n```\nnpm install make-plural-compiler\n```\n\n```js\nimport { Compiler, compileRange } from 'make-plural-compiler'\n```\n\n### `Compiler.load(cldr, ...)`\n\nLoads CLDR rules from one or more `cldr` variables, each of which must be an object formatted like [this][json].\n\nNo plural data is included by default, so you'll need to call this at least once, or otherwise fill the `Compiler.rules` object.\n\nThe default CLDR rules are available from the [cldr-core] package, and may be loaded as seen in the examples below.\n\n[json]: https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/supplemental/plurals.json\n[cldr-core]: https://www.npmjs.com/package/cldr-core\n\n### `new Compiler(lc, { cardinals, ordinals })`\n\nCreates a new compiler for the given locale `lc`.\nIf no direct match for `lc` is found, it is compared case-insensitively to known locales.\n\nThe optional second parameter may contain the following boolean members:\n\n- `cardinals` — if true, rules for cardinal values (1 day, 2 days, etc.) are included\n- `ordinals` — if true, rules for ordinal values (1st, 2nd, etc.) are included\n\nIf the second parameter is undefined, the values are taken from `Compiler.cardinals` (default `true`) and `Compiler.ordinals` (default `false`).\n\n### `Compiler#compile()`\n\nReturns a function that takes an argument `n` and returns its plural category for the given locale.\nThe function has an overloaded `toString(name)` method that may be used to generate a clean string representation of the function, with an optional name `name`.\n\nIf the compiler's `cardinals` and `ordinals` options are both true, the returned function takes a second parameter `ord`.\nThen, if `ord` is true, the function will return the ordinal rather than cardinal category applicable to `n` in locale `lc`.\n\n### `Compiler#test()`\n\nAvailable after `compile()` has been called, `test()` verifies that all of the sample values included in the rules' samples are correctly categorised by teh compiled function.\nEither throws an error or returns `undefined` on success.\n\n```js\nimport plurals from 'cldr-core/supplemental/plurals.json'\nimport ordinals from 'cldr-core/supplemental/ordinals.json'\nimport { Compiler } from 'make-plural-compiler'\n\nCompiler.load(plurals, ordinals)\n// { [Function: Compiler]\n//   cardinals: true,\n//   ordinals: false,\n//   foldWidth: 78,\n//   rules:\n//    { cardinal:\n//       { af: [Object],\n//         ak: [Object],\n//         am: [Object],\n//         [snip many lines...]\n//         yue: [Object],\n//         zh: [Object],\n//         zu: [Object] },\n//      ordinal:\n//       { af: [Object],\n//         am: [Object],\n//         ar: [Object],\n//         [snip slightly fewer lines...]\n//         yue: [Object],\n//         zh: [Object],\n//         zu: [Object] } } }\n\nvar skc = new Compiler('sk') // Note: not including ordinals by default\n// Compiler {\n//   lc: 'sk',\n//   categories: { cardinal: [], ordinal: [] },\n//   parser: Parser {},\n//   tests: Tests { lc: 'sk', ordinal: {}, cardinal: {} },\n//   types: { cardinals: true, ordinals: false } }\n\nvar sk = skc.compile()\n// [Function: anonymous] { toString: [Function (anonymous)] }\n\nskc.test()\n// undefined\n\nsk(1)\n// 'one'\n\nsk(3.0)\n// 'few'\n\nsk('1.0')\n// 'many'\n\nsk('0')\n// 'other'\n\nconsole.log(String(sk))\n// (n) => {\n//   const s = String(n).split('.'), i = s[0], v0 = !s[1];\n//   return n == 1 && v0 ? 'one'\n//     : (i >= 2 && i <= 4) && v0 ? 'few'\n//     : !v0 ? 'many'\n//     : 'other';\n// }\n```\n\n### `compileRange(data)`\n\nCompiles Unicode CLDR plural range data into a corresponding JavaScript function.\n`data` should be an object with keys matching the regular expression `^pluralRange-start-(\\w+)-end-(\\w+)$`, and valid CLDR category identifiers as values.\n\nReturns a function, which when given a `start` and an `end` category as arguments, determines the plural category of the entire range.\n\n## Dependencies\n\nThis library has no explicit dependencies, but it will require CLDR plural rule data to be useful; the [LDML Language Plural Rules] as used in CLDR release 24 and later are supported.\n\nThe canonical source for the data is [cldr-core] (as shown above), but the compiler may also be used e.g. with [cldr-data]:\n\n```js\nconst cldr = require('cldr-data')\nconst { Compiler } = require('make-plural-compiler')\n\nCompiler.load(cldr('supplemental/plurals'), cldr('supplemental/ordinals'))\nconst enc = new Compiler('en')\nconst en = enc.compile()\nen(3, true)\n// 'few'\n```\n\n[ldml language plural rules]: http://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules\n[cldr-data]: https://www.npmjs.org/package/cldr-data\n","readmeFilename":"README.md"}