0
# Core Pluralization
1
2
The main pluralization functions that combine both cardinal and ordinal pluralization in a single interface. These functions determine the appropriate plural category for a given number according to Unicode CLDR rules.
3
4
## Capabilities
5
6
### Main Pluralization Functions
7
8
All 217 language functions follow the same signature, supporting both cardinal and ordinal pluralization through an optional parameter.
9
10
```typescript { .api }
11
/**
12
* Determines the plural category for a number
13
* @param n - The number to pluralize (number or string)
14
* @param ord - Optional boolean for ordinal plurals (true) vs cardinal (false/undefined)
15
* @returns The appropriate plural category
16
*/
17
(n: number | string, ord?: boolean) => PluralCategory;
18
19
type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";
20
```
21
22
### Language Functions
23
24
**Major World Languages:**
25
- `af` - Afrikaans: Returns `"one" | "other"`
26
- `ar` - Arabic: Returns `"zero" | "one" | "two" | "few" | "many" | "other"`
27
- `en` - English: Returns `"one" | "other"` (cardinal), `"one" | "two" | "few" | "other"` (ordinal)
28
- `es` - Spanish: Returns `"one" | "many" | "other"`
29
- `fr` - French: Returns `"one" | "many" | "other"`
30
- `de` - German: Returns `"one" | "other"`
31
- `it` - Italian: Returns `"one" | "many" | "other"`
32
- `ja` - Japanese: Returns `"other"`
33
- `ko` - Korean: Returns `"other"`
34
- `pt` - Portuguese (Brazilian): Returns `"one" | "many" | "other"`
35
- `pt_PT` - Portuguese (European): Returns `"one" | "many" | "other"`
36
- `ru` - Russian: Returns `"one" | "few" | "many" | "other"`
37
- `zh` - Chinese: Returns `"other"`
38
39
**Complex Pluralization Languages:**
40
- `ar` - Arabic: 6 categories (zero, one, two, few, many, other)
41
- `cy` - Welsh: 6 categories with complex ordinal rules
42
- `pl` - Polish: 4 categories (one, few, many, other)
43
- `ro` - Romanian: 3 categories with complex rules
44
- `sl` - Slovenian: 4 categories including "two"
45
46
**Simple Pluralization Languages:**
47
- `zh` - Chinese: Only "other" category
48
- `ja` - Japanese: Only "other" category
49
- `ko` - Korean: Only "other" category
50
- `vi` - Vietnamese: Only "other" category
51
52
### Usage Examples
53
54
**Basic Cardinal Pluralization:**
55
```javascript
56
import { en, fr, ar, pl } from "make-plural";
57
58
// English - simple two-form system
59
en(0); // 'other'
60
en(1); // 'one'
61
en(2); // 'other'
62
63
// French - treats 0 and 1 as singular
64
fr(0); // 'one'
65
fr(1); // 'one'
66
fr(2); // 'many'
67
68
// Arabic - complex 6-category system
69
ar(0); // 'zero'
70
ar(1); // 'one'
71
ar(2); // 'two'
72
ar(3); // 'few' (3-10)
73
ar(11); // 'many' (11-99)
74
ar(100); // 'other' (100+)
75
76
// Polish - complex 4-category system
77
pl(1); // 'one'
78
pl(2); // 'few' (2-4)
79
pl(5); // 'many' (5+)
80
```
81
82
**Ordinal Pluralization:**
83
```javascript
84
import { en, cy } from "make-plural";
85
86
// English ordinals (1st, 2nd, 3rd, 4th+)
87
en(1, true); // 'one' (1st, 21st, 31st...)
88
en(2, true); // 'two' (2nd, 22nd, 32nd...)
89
en(3, true); // 'few' (3rd, 23rd, 33rd...)
90
en(4, true); // 'other' (4th, 5th, 6th...)
91
92
// Welsh - complex ordinal system
93
cy(0, true); // 'zero'
94
cy(1, true); // 'one'
95
cy(2, true); // 'two'
96
cy(3, true); // 'few'
97
cy(6, true); // 'many'
98
cy(10, true); // 'other'
99
```
100
101
**String Input Support:**
102
```javascript
103
import { en, ar } from "make-plural";
104
105
// Supports string representations
106
en("1"); // 'one'
107
en("1.0"); // 'one'
108
en("2.5"); // 'other'
109
110
// Handles decimal numbers
111
ar("0.5"); // 'other'
112
ar("1.0"); // 'one'
113
```
114
115
### Language Coverage Notes
116
117
1. **Portuguese**: Use `pt` for Brazilian Portuguese, `pt_PT` for European Portuguese
118
2. **Indonesian**: Use `id` (modern ISO code), not the deprecated `in` subtag
119
3. **JavaScript identifiers**: Language codes are transformed to valid JavaScript identifiers using safe-identifier package
120
4. **Regional variants**: Some languages have region-specific variants (e.g., `pt_PT`)
121
5. **Ordinal support**: Only 103 of the 217 languages have specific ordinal rules; others fallback to cardinal rules
122
123
### Complete Language Function Listing
124
125
All 217 supported language functions are available as named exports:
126
127
```typescript { .api }
128
// A-C
129
export const af: (n: number | string, ord?: boolean) => "one" | "other";
130
export const ak: (n: number | string, ord?: boolean) => "one" | "other";
131
export const am: (n: number | string, ord?: boolean) => "one" | "other";
132
export const an: (n: number | string, ord?: boolean) => "one" | "other";
133
export const ar: (n: number | string, ord?: boolean) => "zero" | "one" | "two" | "few" | "many" | "other";
134
export const ars: (n: number | string, ord?: boolean) => "zero" | "one" | "two" | "few" | "many" | "other";
135
export const as: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
136
export const asa: (n: number | string, ord?: boolean) => "one" | "other";
137
export const ast: (n: number | string, ord?: boolean) => "one" | "other";
138
export const az: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
139
export const bal: (n: number | string, ord?: boolean) => "one" | "other";
140
export const be: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
141
export const bem: (n: number | string, ord?: boolean) => "one" | "other";
142
export const bez: (n: number | string, ord?: boolean) => "one" | "other";
143
export const bg: (n: number | string, ord?: boolean) => "one" | "other";
144
export const bho: (n: number | string, ord?: boolean) => "one" | "other";
145
export const blo: (n: number | string, ord?: boolean) => "zero" | "one" | "few" | "other";
146
export const bm: (n: number | string, ord?: boolean) => "other";
147
export const bn: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
148
export const bo: (n: number | string, ord?: boolean) => "other";
149
export const br: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
150
export const brx: (n: number | string, ord?: boolean) => "one" | "other";
151
export const bs: (n: number | string, ord?: boolean) => "one" | "few" | "other";
152
export const ca: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
153
export const ce: (n: number | string, ord?: boolean) => "one" | "other";
154
export const ceb: (n: number | string, ord?: boolean) => "one" | "other";
155
export const cgg: (n: number | string, ord?: boolean) => "one" | "other";
156
export const chr: (n: number | string, ord?: boolean) => "one" | "other";
157
export const ckb: (n: number | string, ord?: boolean) => "one" | "other";
158
export const cs: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
159
export const cy: (n: number | string, ord?: boolean) => "zero" | "one" | "two" | "few" | "many" | "other";
160
161
// D-H
162
export const da: (n: number | string, ord?: boolean) => "one" | "other";
163
export const de: (n: number | string, ord?: boolean) => "one" | "other";
164
export const doi: (n: number | string, ord?: boolean) => "one" | "other";
165
export const dsb: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other";
166
export const dv: (n: number | string, ord?: boolean) => "one" | "other";
167
export const dz: (n: number | string, ord?: boolean) => "other";
168
export const ee: (n: number | string, ord?: boolean) => "one" | "other";
169
export const el: (n: number | string, ord?: boolean) => "one" | "other";
170
export const en: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other";
171
export const eo: (n: number | string, ord?: boolean) => "one" | "other";
172
export const es: (n: number | string, ord?: boolean) => "one" | "many" | "other";
173
export const et: (n: number | string, ord?: boolean) => "one" | "other";
174
export const eu: (n: number | string, ord?: boolean) => "one" | "other";
175
export const fa: (n: number | string, ord?: boolean) => "one" | "other";
176
export const ff: (n: number | string, ord?: boolean) => "one" | "other";
177
export const fi: (n: number | string, ord?: boolean) => "one" | "other";
178
export const fil: (n: number | string, ord?: boolean) => "one" | "other";
179
export const fo: (n: number | string, ord?: boolean) => "one" | "other";
180
export const fr: (n: number | string, ord?: boolean) => "one" | "many" | "other";
181
export const fur: (n: number | string, ord?: boolean) => "one" | "other";
182
export const fy: (n: number | string, ord?: boolean) => "one" | "other";
183
export const ga: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
184
export const gd: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other";
185
export const gl: (n: number | string, ord?: boolean) => "one" | "other";
186
export const gsw: (n: number | string, ord?: boolean) => "one" | "other";
187
export const gu: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
188
export const guw: (n: number | string, ord?: boolean) => "one" | "other";
189
export const gv: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
190
export const ha: (n: number | string, ord?: boolean) => "one" | "other";
191
export const haw: (n: number | string, ord?: boolean) => "one" | "other";
192
export const he: (n: number | string, ord?: boolean) => "one" | "two" | "other";
193
export const hi: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
194
export const hnj: (n: number | string, ord?: boolean) => "other";
195
export const hr: (n: number | string, ord?: boolean) => "one" | "few" | "other";
196
export const hsb: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other";
197
export const hu: (n: number | string, ord?: boolean) => "one" | "other";
198
export const hy: (n: number | string, ord?: boolean) => "one" | "other";
199
200
// I-P
201
export const ia: (n: number | string, ord?: boolean) => "one" | "other";
202
export const id: (n: number | string, ord?: boolean) => "other";
203
export const ig: (n: number | string, ord?: boolean) => "other";
204
export const ii: (n: number | string, ord?: boolean) => "other";
205
export const io: (n: number | string, ord?: boolean) => "one" | "other";
206
export const is: (n: number | string, ord?: boolean) => "one" | "other";
207
export const it: (n: number | string, ord?: boolean) => "one" | "many" | "other";
208
export const iu: (n: number | string, ord?: boolean) => "one" | "two" | "other";
209
export const ja: (n: number | string, ord?: boolean) => "other";
210
export const jbo: (n: number | string, ord?: boolean) => "other";
211
export const jgo: (n: number | string, ord?: boolean) => "one" | "other";
212
export const jmc: (n: number | string, ord?: boolean) => "one" | "other";
213
export const jv: (n: number | string, ord?: boolean) => "other";
214
export const jw: (n: number | string, ord?: boolean) => "other";
215
export const ka: (n: number | string, ord?: boolean) => "one" | "many" | "other";
216
export const kab: (n: number | string, ord?: boolean) => "one" | "other";
217
export const kaj: (n: number | string, ord?: boolean) => "one" | "other";
218
export const kcg: (n: number | string, ord?: boolean) => "one" | "other";
219
export const kde: (n: number | string, ord?: boolean) => "other";
220
export const kea: (n: number | string, ord?: boolean) => "other";
221
export const kk: (n: number | string, ord?: boolean) => "one" | "many" | "other";
222
export const kkj: (n: number | string, ord?: boolean) => "one" | "other";
223
export const kl: (n: number | string, ord?: boolean) => "one" | "other";
224
export const km: (n: number | string, ord?: boolean) => "other";
225
export const kn: (n: number | string, ord?: boolean) => "one" | "other";
226
export const ko: (n: number | string, ord?: boolean) => "other";
227
export const ks: (n: number | string, ord?: boolean) => "one" | "other";
228
export const ksb: (n: number | string, ord?: boolean) => "one" | "other";
229
export const ksh: (n: number | string, ord?: boolean) => "zero" | "one" | "other";
230
export const ku: (n: number | string, ord?: boolean) => "one" | "other";
231
export const kw: (n: number | string, ord?: boolean) => "zero" | "one" | "two" | "few" | "many" | "other";
232
export const ky: (n: number | string, ord?: boolean) => "one" | "other";
233
export const lag: (n: number | string, ord?: boolean) => "zero" | "one" | "other";
234
export const lb: (n: number | string, ord?: boolean) => "one" | "other";
235
export const lg: (n: number | string, ord?: boolean) => "one" | "other";
236
export const lij: (n: number | string, ord?: boolean) => "one" | "other";
237
export const lkt: (n: number | string, ord?: boolean) => "other";
238
export const ln: (n: number | string, ord?: boolean) => "one" | "other";
239
export const lo: (n: number | string, ord?: boolean) => "other";
240
export const lt: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
241
export const lv: (n: number | string, ord?: boolean) => "zero" | "one" | "other";
242
export const mas: (n: number | string, ord?: boolean) => "one" | "other";
243
export const mg: (n: number | string, ord?: boolean) => "one" | "other";
244
export const mgo: (n: number | string, ord?: boolean) => "one" | "other";
245
export const mk: (n: number | string, ord?: boolean) => "one" | "other";
246
export const ml: (n: number | string, ord?: boolean) => "one" | "other";
247
export const mn: (n: number | string, ord?: boolean) => "one" | "other";
248
export const mo: (n: number | string, ord?: boolean) => "one" | "few" | "other";
249
export const mr: (n: number | string, ord?: boolean) => "one" | "other";
250
export const ms: (n: number | string, ord?: boolean) => "other";
251
export const mt: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "many" | "other";
252
export const my: (n: number | string, ord?: boolean) => "other";
253
export const nah: (n: number | string, ord?: boolean) => "one" | "other";
254
export const naq: (n: number | string, ord?: boolean) => "one" | "two" | "other";
255
export const nb: (n: number | string, ord?: boolean) => "one" | "other";
256
export const nd: (n: number | string, ord?: boolean) => "one" | "other";
257
export const ne: (n: number | string, ord?: boolean) => "one" | "other";
258
export const nl: (n: number | string, ord?: boolean) => "one" | "other";
259
export const nn: (n: number | string, ord?: boolean) => "one" | "other";
260
export const nnh: (n: number | string, ord?: boolean) => "one" | "other";
261
export const no: (n: number | string, ord?: boolean) => "one" | "other";
262
export const nqo: (n: number | string, ord?: boolean) => "other";
263
export const nr: (n: number | string, ord?: boolean) => "one" | "other";
264
export const nso: (n: number | string, ord?: boolean) => "one" | "other";
265
export const ny: (n: number | string, ord?: boolean) => "one" | "other";
266
export const nyn: (n: number | string, ord?: boolean) => "one" | "other";
267
export const om: (n: number | string, ord?: boolean) => "one" | "other";
268
export const or: (n: number | string, ord?: boolean) => "one" | "other";
269
export const os: (n: number | string, ord?: boolean) => "one" | "other";
270
export const osa: (n: number | string, ord?: boolean) => "other";
271
export const pa: (n: number | string, ord?: boolean) => "one" | "other";
272
export const pap: (n: number | string, ord?: boolean) => "one" | "other";
273
export const pcm: (n: number | string, ord?: boolean) => "one" | "other";
274
export const pl: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
275
export const prg: (n: number | string, ord?: boolean) => "zero" | "one" | "other";
276
export const ps: (n: number | string, ord?: boolean) => "one" | "other";
277
export const pt: (n: number | string, ord?: boolean) => "one" | "many" | "other";
278
export const pt_PT: (n: number | string, ord?: boolean) => "one" | "many" | "other";
279
280
// R-Z
281
export const rm: (n: number | string, ord?: boolean) => "one" | "other";
282
export const ro: (n: number | string, ord?: boolean) => "one" | "few" | "other";
283
export const rof: (n: number | string, ord?: boolean) => "one" | "other";
284
export const ru: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
285
export const rwk: (n: number | string, ord?: boolean) => "one" | "other";
286
export const sah: (n: number | string, ord?: boolean) => "other";
287
export const saq: (n: number | string, ord?: boolean) => "one" | "other";
288
export const sat: (n: number | string, ord?: boolean) => "one" | "two" | "other";
289
export const sc: (n: number | string, ord?: boolean) => "one" | "other";
290
export const scn: (n: number | string, ord?: boolean) => "one" | "other";
291
export const sd: (n: number | string, ord?: boolean) => "one" | "other";
292
export const sdh: (n: number | string, ord?: boolean) => "one" | "other";
293
export const se: (n: number | string, ord?: boolean) => "one" | "two" | "other";
294
export const seh: (n: number | string, ord?: boolean) => "one" | "other";
295
export const ses: (n: number | string, ord?: boolean) => "other";
296
export const sg: (n: number | string, ord?: boolean) => "other";
297
export const sh: (n: number | string, ord?: boolean) => "one" | "few" | "other";
298
export const shi: (n: number | string, ord?: boolean) => "one" | "few" | "other";
299
export const si: (n: number | string, ord?: boolean) => "one" | "other";
300
export const sk: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
301
export const sl: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other";
302
export const sma: (n: number | string, ord?: boolean) => "one" | "two" | "other";
303
export const smi: (n: number | string, ord?: boolean) => "one" | "two" | "other";
304
export const smj: (n: number | string, ord?: boolean) => "one" | "two" | "other";
305
export const smn: (n: number | string, ord?: boolean) => "one" | "two" | "other";
306
export const sms: (n: number | string, ord?: boolean) => "one" | "two" | "other";
307
export const sn: (n: number | string, ord?: boolean) => "one" | "other";
308
export const so: (n: number | string, ord?: boolean) => "one" | "other";
309
export const sq: (n: number | string, ord?: boolean) => "one" | "other";
310
export const sr: (n: number | string, ord?: boolean) => "one" | "few" | "other";
311
export const ss: (n: number | string, ord?: boolean) => "one" | "other";
312
export const ssy: (n: number | string, ord?: boolean) => "one" | "other";
313
export const st: (n: number | string, ord?: boolean) => "one" | "other";
314
export const su: (n: number | string, ord?: boolean) => "other";
315
export const sv: (n: number | string, ord?: boolean) => "one" | "other";
316
export const sw: (n: number | string, ord?: boolean) => "one" | "other";
317
export const syr: (n: number | string, ord?: boolean) => "one" | "other";
318
export const ta: (n: number | string, ord?: boolean) => "one" | "other";
319
export const te: (n: number | string, ord?: boolean) => "one" | "other";
320
export const teo: (n: number | string, ord?: boolean) => "one" | "other";
321
export const th: (n: number | string, ord?: boolean) => "other";
322
export const ti: (n: number | string, ord?: boolean) => "one" | "other";
323
export const tig: (n: number | string, ord?: boolean) => "one" | "other";
324
export const tk: (n: number | string, ord?: boolean) => "one" | "other";
325
export const tl: (n: number | string, ord?: boolean) => "one" | "other";
326
export const tn: (n: number | string, ord?: boolean) => "one" | "other";
327
export const to: (n: number | string, ord?: boolean) => "other";
328
export const tpi: (n: number | string, ord?: boolean) => "other";
329
export const tr: (n: number | string, ord?: boolean) => "one" | "other";
330
export const ts: (n: number | string, ord?: boolean) => "one" | "other";
331
export const tzm: (n: number | string, ord?: boolean) => "one" | "other";
332
export const ug: (n: number | string, ord?: boolean) => "one" | "other";
333
export const uk: (n: number | string, ord?: boolean) => "one" | "few" | "many" | "other";
334
export const und: (n: number | string, ord?: boolean) => "other";
335
export const ur: (n: number | string, ord?: boolean) => "one" | "other";
336
export const uz: (n: number | string, ord?: boolean) => "one" | "other";
337
export const ve: (n: number | string, ord?: boolean) => "one" | "other";
338
export const vec: (n: number | string, ord?: boolean) => "one" | "many" | "other";
339
export const vi: (n: number | string, ord?: boolean) => "one" | "other";
340
export const vo: (n: number | string, ord?: boolean) => "one" | "other";
341
export const vun: (n: number | string, ord?: boolean) => "one" | "other";
342
export const wa: (n: number | string, ord?: boolean) => "one" | "other";
343
export const wae: (n: number | string, ord?: boolean) => "one" | "other";
344
export const wo: (n: number | string, ord?: boolean) => "other";
345
export const xh: (n: number | string, ord?: boolean) => "one" | "other";
346
export const xog: (n: number | string, ord?: boolean) => "one" | "other";
347
export const yi: (n: number | string, ord?: boolean) => "one" | "other";
348
export const yo: (n: number | string, ord?: boolean) => "other";
349
export const yue: (n: number | string, ord?: boolean) => "other";
350
export const zh: (n: number | string, ord?: boolean) => "other";
351
export const zu: (n: number | string, ord?: boolean) => "one" | "other";
352
```
353
354
### Performance Characteristics
355
356
- **Pre-compiled**: All functions are pre-compiled for maximum runtime performance
357
- **Tree-shakable**: Import only the language functions you need
358
- **Compact**: Each function is highly optimized for size
359
- **No dependencies**: Self-contained with no runtime dependencies
360
- **Type safe**: Full TypeScript support with accurate return type unions