make-plural 7.5.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -10
- package/cardinals.js +269 -499
- package/examples.js +224 -231
- package/ordinals.js +134 -248
- package/package.json +9 -61
- package/pluralCategories.js +229 -236
- package/plurals.js +300 -530
- package/ranges.js +93 -190
- package/cardinals.mjs +0 -472
- package/examples.mjs +0 -232
- package/ordinals.mjs +0 -217
- package/pluralCategories.mjs +0 -230
- package/plurals.mjs +0 -713
- package/ranges.mjs +0 -106
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# make-plural
|
|
2
2
|
|
|
3
|
-
`make-plural` provides JavaScript functions determining the pluralization categories of the approximately
|
|
3
|
+
`make-plural` provides JavaScript functions determining the pluralization categories of the approximately 220 languages included in the [Unicode CLDR].
|
|
4
4
|
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).
|
|
5
5
|
It's used internally by the [intl-pluralrules] polyfill.
|
|
6
6
|
|
|
7
7
|
The categorization functions are pre-compiled, require no runtime dependencies, and should compress to about 2.5kB.
|
|
8
|
-
The ES
|
|
8
|
+
The ES modules are designed to work well with tree-shaking, allowing for further size savings.
|
|
9
9
|
In 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].
|
|
10
10
|
|
|
11
11
|
[intl-pluralrules]: https://www.npmjs.com/package/intl-pluralrules
|
|
@@ -28,7 +28,7 @@ import * as Categories from 'make-plural/pluralCategories'
|
|
|
28
28
|
import * as PluralRanges from 'make-plural/ranges'
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Each of the endpoints is available
|
|
31
|
+
Each of the endpoints is available as ES modules only.
|
|
32
32
|
- `Cardinals`, `Ordinals` and `Plurals` each export a set of functions keyed by locale code,
|
|
33
33
|
returning the pluralization category for the input (either a number or a string representation of a number).
|
|
34
34
|
`Plurals` functions also accept a second boolean parameter to return
|
|
@@ -44,16 +44,16 @@ Each of the endpoints is available with both UMD (.js) and ES (.mjs) packaging.
|
|
|
44
44
|
- `Examples` provide sample numeric values for each language's categories.
|
|
45
45
|
|
|
46
46
|
The object keys are named using the corresponding 2-3 character [language code].
|
|
47
|
-
Due to JavaScript identifier restrictions, there
|
|
48
|
-
Portugese as spoken in Portugal (`pt-PT`; `pt` is Brazilian Portuguese) is available as `pt_PT
|
|
49
|
-
The transformation used for
|
|
47
|
+
Due to JavaScript identifier restrictions, there is one exception:
|
|
48
|
+
Portugese as spoken in Portugal (`pt-PT`; `pt` is Brazilian Portuguese) is available as `pt_PT`.
|
|
49
|
+
The transformation used for locale names is available as [safe-identifier] on npm.
|
|
50
50
|
|
|
51
51
|
[language]: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
|
|
52
52
|
[language code]: https://www.unicode.org/cldr/charts/latest/supplemental/languages_and_scripts.html
|
|
53
53
|
[safe-identifier]: https://www.npmjs.com/package/safe-identifier
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
Tree shaking should be able drop all but the explicitly used functions from the output,
|
|
56
|
+
provided that **named rather than wildcard imports** are used.
|
|
57
57
|
|
|
58
58
|
```js
|
|
59
59
|
import { en } from 'make-plural'
|
|
@@ -78,8 +78,7 @@ import { en as ordinalEn } from 'make-plural/ordinals'
|
|
|
78
78
|
ordinalEn(3) // 'few'
|
|
79
79
|
|
|
80
80
|
import * as Categories from 'make-plural/pluralCategories'
|
|
81
|
-
// {
|
|
82
|
-
// af: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },
|
|
81
|
+
// { af: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },
|
|
83
82
|
// ak: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },
|
|
84
83
|
// am: { cardinal: [ 'one', 'other' ], ordinal: [ 'other' ] },
|
|
85
84
|
// ar:
|