make-plural 7.4.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.d.ts +8 -1
- package/cardinals.js +283 -504
- package/examples.d.ts +9 -2
- package/examples.js +224 -224
- package/examples.json +9 -2
- package/ordinals.d.ts +5 -0
- package/ordinals.js +140 -235
- package/package.json +9 -61
- package/pluralCategories.d.ts +8 -1
- package/pluralCategories.js +229 -229
- package/plurals.d.ts +7 -0
- package/plurals.js +331 -514
- package/ranges.js +93 -190
- package/cardinals.mjs +0 -470
- package/examples.mjs +0 -225
- package/ordinals.mjs +0 -203
- package/pluralCategories.mjs +0 -223
- package/plurals.mjs +0 -673
- 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:
|
package/cardinals.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export const cgg: (n: number | string) => "one" | "other";
|
|
|
30
30
|
export const chr: (n: number | string) => "one" | "other";
|
|
31
31
|
export const ckb: (n: number | string) => "one" | "other";
|
|
32
32
|
export const cs: (n: number | string) => "one" | "few" | "many" | "other";
|
|
33
|
+
export const csw: (n: number | string) => "one" | "other";
|
|
34
|
+
export const cv: (n: number | string) => "zero" | "one" | "other";
|
|
33
35
|
export const cy: (n: number | string) => "zero" | "one" | "two" | "few" | "many" | "other";
|
|
34
36
|
export const da: (n: number | string) => "one" | "other";
|
|
35
37
|
export const de: (n: number | string) => "one" | "other";
|
|
@@ -70,6 +72,7 @@ export const hu: (n: number | string) => "one" | "other";
|
|
|
70
72
|
export const hy: (n: number | string) => "one" | "other";
|
|
71
73
|
export const ia: (n: number | string) => "one" | "other";
|
|
72
74
|
export const id: (n: number | string) => "other";
|
|
75
|
+
export const ie: (n: number | string) => "one" | "other";
|
|
73
76
|
export const ig: (n: number | string) => "other";
|
|
74
77
|
export const ii: (n: number | string) => "other";
|
|
75
78
|
export const io: (n: number | string) => "one" | "other";
|
|
@@ -94,6 +97,8 @@ export const kl: (n: number | string) => "one" | "other";
|
|
|
94
97
|
export const km: (n: number | string) => "other";
|
|
95
98
|
export const kn: (n: number | string) => "one" | "other";
|
|
96
99
|
export const ko: (n: number | string) => "other";
|
|
100
|
+
export const kok: (n: number | string) => "one" | "other";
|
|
101
|
+
export const kok_Latn: (n: number | string) => "one" | "other";
|
|
97
102
|
export const ks: (n: number | string) => "one" | "other";
|
|
98
103
|
export const ksb: (n: number | string) => "one" | "other";
|
|
99
104
|
export const ksh: (n: number | string) => "zero" | "one" | "other";
|
|
@@ -105,6 +110,7 @@ export const lb: (n: number | string) => "one" | "other";
|
|
|
105
110
|
export const lg: (n: number | string) => "one" | "other";
|
|
106
111
|
export const lij: (n: number | string) => "one" | "other";
|
|
107
112
|
export const lkt: (n: number | string) => "other";
|
|
113
|
+
export const lld: (n: number | string) => "one" | "many" | "other";
|
|
108
114
|
export const ln: (n: number | string) => "one" | "other";
|
|
109
115
|
export const lo: (n: number | string) => "other";
|
|
110
116
|
export const lt: (n: number | string) => "one" | "few" | "many" | "other";
|
|
@@ -155,13 +161,14 @@ export const sah: (n: number | string) => "other";
|
|
|
155
161
|
export const saq: (n: number | string) => "one" | "other";
|
|
156
162
|
export const sat: (n: number | string) => "one" | "two" | "other";
|
|
157
163
|
export const sc: (n: number | string) => "one" | "other";
|
|
158
|
-
export const scn: (n: number | string) => "one" | "other";
|
|
164
|
+
export const scn: (n: number | string) => "one" | "many" | "other";
|
|
159
165
|
export const sd: (n: number | string) => "one" | "other";
|
|
160
166
|
export const sdh: (n: number | string) => "one" | "other";
|
|
161
167
|
export const se: (n: number | string) => "one" | "two" | "other";
|
|
162
168
|
export const seh: (n: number | string) => "one" | "other";
|
|
163
169
|
export const ses: (n: number | string) => "other";
|
|
164
170
|
export const sg: (n: number | string) => "other";
|
|
171
|
+
export const sgs: (n: number | string) => "one" | "two" | "few" | "many" | "other";
|
|
165
172
|
export const sh: (n: number | string) => "one" | "few" | "other";
|
|
166
173
|
export const shi: (n: number | string) => "one" | "few" | "other";
|
|
167
174
|
export const si: (n: number | string) => "one" | "other";
|