@formatjs/intl-pluralrules 6.2.4 → 6.3.2

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.
Files changed (241) hide show
  1. package/index.d.ts +113 -65
  2. package/index.js +965 -64
  3. package/index.js.map +1 -0
  4. package/locale-data/af.js +15 -0
  5. package/locale-data/ak.js +15 -0
  6. package/locale-data/am.js +16 -0
  7. package/locale-data/an.js +15 -0
  8. package/locale-data/ar.js +23 -0
  9. package/locale-data/ars.js +23 -0
  10. package/locale-data/as.js +24 -0
  11. package/locale-data/asa.js +15 -0
  12. package/locale-data/ast.js +16 -0
  13. package/locale-data/az.js +22 -0
  14. package/locale-data/bal.js +17 -0
  15. package/locale-data/be.js +21 -0
  16. package/locale-data/bem.js +15 -0
  17. package/locale-data/bez.js +15 -0
  18. package/locale-data/bg.js +15 -0
  19. package/locale-data/bho.js +15 -0
  20. package/locale-data/bm.js +4 -0
  21. package/locale-data/bn.js +24 -0
  22. package/locale-data/bo.js +4 -0
  23. package/locale-data/br.js +21 -0
  24. package/locale-data/brx.js +15 -0
  25. package/locale-data/bs.js +19 -0
  26. package/locale-data/ca.js +26 -0
  27. package/locale-data/ce.js +15 -0
  28. package/locale-data/ceb.js +17 -0
  29. package/locale-data/cgg.js +15 -0
  30. package/locale-data/chr.js +15 -0
  31. package/locale-data/ckb.js +15 -0
  32. package/locale-data/cs.js +20 -0
  33. package/locale-data/cy.js +33 -0
  34. package/locale-data/da.js +18 -0
  35. package/locale-data/de.js +16 -0
  36. package/locale-data/doi.js +16 -0
  37. package/locale-data/dsb.js +21 -0
  38. package/locale-data/dv.js +15 -0
  39. package/locale-data/dz.js +4 -0
  40. package/locale-data/ee.js +15 -0
  41. package/locale-data/el.js +15 -0
  42. package/locale-data/en.js +23 -0
  43. package/locale-data/eo.js +15 -0
  44. package/locale-data/es.js +20 -0
  45. package/locale-data/et.js +16 -0
  46. package/locale-data/eu.js +15 -0
  47. package/locale-data/fa.js +16 -0
  48. package/locale-data/ff.js +15 -0
  49. package/locale-data/fi.js +16 -0
  50. package/locale-data/fil.js +20 -0
  51. package/locale-data/fo.js +15 -0
  52. package/locale-data/fr.js +22 -0
  53. package/locale-data/fur.js +15 -0
  54. package/locale-data/fy.js +16 -0
  55. package/locale-data/ga.js +23 -0
  56. package/locale-data/gd.js +25 -0
  57. package/locale-data/gl.js +16 -0
  58. package/locale-data/gsw.js +15 -0
  59. package/locale-data/gu.js +24 -0
  60. package/locale-data/guw.js +15 -0
  61. package/locale-data/gv.js +22 -0
  62. package/locale-data/ha.js +15 -0
  63. package/locale-data/haw.js +15 -0
  64. package/locale-data/he.js +18 -0
  65. package/locale-data/hi.js +24 -0
  66. package/locale-data/hnj.js +4 -0
  67. package/locale-data/hr.js +19 -0
  68. package/locale-data/hsb.js +21 -0
  69. package/locale-data/hu.js +17 -0
  70. package/locale-data/hy.js +18 -0
  71. package/locale-data/ia.js +16 -0
  72. package/locale-data/id.js +4 -0
  73. package/locale-data/ig.js +4 -0
  74. package/locale-data/ii.js +4 -0
  75. package/locale-data/io.js +16 -0
  76. package/locale-data/is.js +17 -0
  77. package/locale-data/it.js +22 -0
  78. package/locale-data/iu.js +17 -0
  79. package/locale-data/ja.js +4 -0
  80. package/locale-data/jbo.js +4 -0
  81. package/locale-data/jgo.js +15 -0
  82. package/locale-data/jmc.js +15 -0
  83. package/locale-data/jv.js +4 -0
  84. package/locale-data/jw.js +4 -0
  85. package/locale-data/ka.js +20 -0
  86. package/locale-data/kab.js +15 -0
  87. package/locale-data/kaj.js +15 -0
  88. package/locale-data/kcg.js +15 -0
  89. package/locale-data/kde.js +4 -0
  90. package/locale-data/kea.js +4 -0
  91. package/locale-data/kk.js +17 -0
  92. package/locale-data/kkj.js +15 -0
  93. package/locale-data/kl.js +15 -0
  94. package/locale-data/km.js +4 -0
  95. package/locale-data/kn.js +16 -0
  96. package/locale-data/ko.js +4 -0
  97. package/locale-data/ks.js +15 -0
  98. package/locale-data/ksb.js +15 -0
  99. package/locale-data/ksh.js +17 -0
  100. package/locale-data/ku.js +15 -0
  101. package/locale-data/kw.js +27 -0
  102. package/locale-data/ky.js +15 -0
  103. package/locale-data/lag.js +18 -0
  104. package/locale-data/lb.js +15 -0
  105. package/locale-data/lg.js +15 -0
  106. package/locale-data/lij.js +19 -0
  107. package/locale-data/lkt.js +4 -0
  108. package/locale-data/ln.js +15 -0
  109. package/locale-data/lo.js +15 -0
  110. package/locale-data/lt.js +21 -0
  111. package/locale-data/lv.js +19 -0
  112. package/locale-data/mas.js +15 -0
  113. package/locale-data/mg.js +15 -0
  114. package/locale-data/mgo.js +15 -0
  115. package/locale-data/mk.js +23 -0
  116. package/locale-data/ml.js +15 -0
  117. package/locale-data/mn.js +15 -0
  118. package/locale-data/mo.js +21 -0
  119. package/locale-data/mr.js +21 -0
  120. package/locale-data/ms.js +15 -0
  121. package/locale-data/mt.js +21 -0
  122. package/locale-data/my.js +4 -0
  123. package/locale-data/nah.js +15 -0
  124. package/locale-data/naq.js +17 -0
  125. package/locale-data/nb.js +15 -0
  126. package/locale-data/nd.js +15 -0
  127. package/locale-data/ne.js +17 -0
  128. package/locale-data/nl.js +16 -0
  129. package/locale-data/nn.js +15 -0
  130. package/locale-data/nnh.js +15 -0
  131. package/locale-data/no.js +15 -0
  132. package/locale-data/nqo.js +4 -0
  133. package/locale-data/nr.js +15 -0
  134. package/locale-data/nso.js +15 -0
  135. package/locale-data/ny.js +15 -0
  136. package/locale-data/nyn.js +15 -0
  137. package/locale-data/om.js +15 -0
  138. package/locale-data/or.js +23 -0
  139. package/locale-data/os.js +15 -0
  140. package/locale-data/osa.js +4 -0
  141. package/locale-data/pa.js +15 -0
  142. package/locale-data/pap.js +15 -0
  143. package/locale-data/pcm.js +16 -0
  144. package/locale-data/pl.js +20 -0
  145. package/locale-data/prg.js +19 -0
  146. package/locale-data/ps.js +15 -0
  147. package/locale-data/pt-PT.js +19 -0
  148. package/locale-data/pt.js +19 -0
  149. package/locale-data/rm.js +15 -0
  150. package/locale-data/ro.js +21 -0
  151. package/locale-data/rof.js +15 -0
  152. package/locale-data/ru.js +20 -0
  153. package/locale-data/rwk.js +15 -0
  154. package/locale-data/sah.js +4 -0
  155. package/locale-data/saq.js +15 -0
  156. package/locale-data/sat.js +17 -0
  157. package/locale-data/sc.js +19 -0
  158. package/locale-data/scn.js +22 -0
  159. package/locale-data/sd.js +15 -0
  160. package/locale-data/sdh.js +15 -0
  161. package/locale-data/se.js +17 -0
  162. package/locale-data/seh.js +15 -0
  163. package/locale-data/ses.js +4 -0
  164. package/locale-data/sg.js +4 -0
  165. package/locale-data/sh.js +19 -0
  166. package/locale-data/shi.js +18 -0
  167. package/locale-data/si.js +18 -0
  168. package/locale-data/sk.js +20 -0
  169. package/locale-data/sl.js +20 -0
  170. package/locale-data/sma.js +17 -0
  171. package/locale-data/smi.js +17 -0
  172. package/locale-data/smj.js +17 -0
  173. package/locale-data/smn.js +17 -0
  174. package/locale-data/sms.js +17 -0
  175. package/locale-data/sn.js +15 -0
  176. package/locale-data/so.js +15 -0
  177. package/locale-data/sq.js +19 -0
  178. package/locale-data/sr.js +19 -0
  179. package/locale-data/ss.js +15 -0
  180. package/locale-data/ssy.js +15 -0
  181. package/locale-data/st.js +15 -0
  182. package/locale-data/su.js +4 -0
  183. package/locale-data/sv.js +19 -0
  184. package/locale-data/sw.js +16 -0
  185. package/locale-data/syr.js +15 -0
  186. package/locale-data/ta.js +15 -0
  187. package/locale-data/te.js +15 -0
  188. package/locale-data/teo.js +15 -0
  189. package/locale-data/th.js +4 -0
  190. package/locale-data/ti.js +15 -0
  191. package/locale-data/tig.js +15 -0
  192. package/locale-data/tk.js +17 -0
  193. package/locale-data/tl.js +20 -0
  194. package/locale-data/tn.js +15 -0
  195. package/locale-data/to.js +4 -0
  196. package/locale-data/tpi.js +4 -0
  197. package/locale-data/tr.js +15 -0
  198. package/locale-data/ts.js +15 -0
  199. package/locale-data/tzm.js +15 -0
  200. package/locale-data/ug.js +15 -0
  201. package/locale-data/uk.js +23 -0
  202. package/locale-data/und.js +4 -0
  203. package/locale-data/ur.js +16 -0
  204. package/locale-data/uz.js +15 -0
  205. package/locale-data/ve.js +15 -0
  206. package/locale-data/vi.js +15 -0
  207. package/locale-data/vo.js +15 -0
  208. package/locale-data/vun.js +15 -0
  209. package/locale-data/wa.js +15 -0
  210. package/locale-data/wae.js +15 -0
  211. package/locale-data/wo.js +4 -0
  212. package/locale-data/xh.js +15 -0
  213. package/locale-data/xog.js +15 -0
  214. package/locale-data/yi.js +16 -0
  215. package/locale-data/yo.js +4 -0
  216. package/locale-data/yue.js +4 -0
  217. package/locale-data/zh.js +4 -0
  218. package/locale-data/zu.js +16 -0
  219. package/package.json +5 -6
  220. package/polyfill-force.d.ts +1 -1
  221. package/polyfill-force.js +1130 -1
  222. package/polyfill-force.js.map +1 -0
  223. package/polyfill.d.ts +1 -1
  224. package/polyfill.iife.js +5522 -7581
  225. package/polyfill.js +1359 -2
  226. package/polyfill.js.map +1 -0
  227. package/should-polyfill.d.ts +5 -1
  228. package/should-polyfill.js +227 -8
  229. package/should-polyfill.js.map +1 -0
  230. package/abstract/GetOperands.d.ts +0 -59
  231. package/abstract/GetOperands.js +0 -50
  232. package/abstract/InitializePluralRules.d.ts +0 -8
  233. package/abstract/InitializePluralRules.js +0 -31
  234. package/abstract/ResolvePlural.d.ts +0 -43
  235. package/abstract/ResolvePlural.js +0 -75
  236. package/abstract/ResolvePluralRange.d.ts +0 -23
  237. package/abstract/ResolvePluralRange.js +0 -59
  238. package/get_internal_slots.d.ts +0 -3
  239. package/get_internal_slots.js +0 -10
  240. package/supported-locales.generated.d.ts +0 -1
  241. package/supported-locales.generated.js +0 -217
package/index.d.ts CHANGED
@@ -1,4 +1,49 @@
1
- import { type LDMLPluralRule, type NumberFormatDigitInternalSlots, type PluralRulesData, type PluralRulesLocaleData } from "@formatjs/ecma402-abstract";
1
+ import { Decimal as Decimal$1 } from "@formatjs/bigdecimal";
2
+
3
+ //#region packages/ecma402-abstract/types/core.d.ts
4
+ type Locale = string;
5
+ interface LocaleData<T> {
6
+ data: T;
7
+ locale: Locale;
8
+ }
9
+ //#endregion
10
+ //#region packages/ecma402-abstract/types/plural-rules.d.ts
11
+ type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
12
+ interface PluralRangesData {
13
+ cardinal?: Record<string, LDMLPluralRule>;
14
+ ordinal?: Record<string, LDMLPluralRule>;
15
+ }
16
+ interface PluralRulesData {
17
+ categories: {
18
+ cardinal: string[];
19
+ ordinal: string[];
20
+ };
21
+ fn: (val: number | string, ord?: boolean, exponent?: number) => LDMLPluralRule;
22
+ pluralRanges?: PluralRangesData;
23
+ }
24
+ type PluralRulesLocaleData = LocaleData<PluralRulesData>;
25
+ //#endregion
26
+ //#region packages/ecma402-abstract/types/number.d.ts
27
+ type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
28
+ type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
29
+ type NumberFormatRoundingType = "morePrecision" | "lessPrecision" | "significantDigits" | "fractionDigits";
30
+ type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
31
+ interface NumberFormatDigitInternalSlots {
32
+ minimumIntegerDigits: number;
33
+ minimumSignificantDigits: number;
34
+ maximumSignificantDigits: number;
35
+ roundingType: NumberFormatRoundingType;
36
+ minimumFractionDigits: number;
37
+ maximumFractionDigits: number;
38
+ notation: NumberFormatNotation;
39
+ roundingIncrement: number;
40
+ roundingMode: RoundingModeType;
41
+ trailingZeroDisplay: TrailingZeroDisplay;
42
+ roundingPriority: RoundingPriorityType;
43
+ }
44
+ type TrailingZeroDisplay = "auto" | "stripIfInteger";
45
+ //#endregion
46
+ //#region packages/intl-pluralrules/index.d.ts
2
47
  /**
3
48
  * Type augmentation for Intl.PluralRules
4
49
  *
@@ -9,70 +54,73 @@ import { type LDMLPluralRule, type NumberFormatDigitInternalSlots, type PluralRu
9
54
  * Mirrors Intl.NumberFormat notation option for proper plural selection with compact numbers
10
55
  */
11
56
  declare global {
12
- namespace Intl {
13
- interface PluralRules {
14
- selectRange(start: number | bigint, end: number | bigint): LDMLPluralRule;
15
- }
16
- interface PluralRulesOptions {
17
- notation?: "standard" | "compact";
18
- compactDisplay?: "short" | "long";
19
- }
20
- }
57
+ namespace Intl {
58
+ interface PluralRules {
59
+ selectRange(start: number | bigint, end: number | bigint): LDMLPluralRule;
60
+ }
61
+ interface PluralRulesOptions {
62
+ notation?: "standard" | "compact";
63
+ compactDisplay?: "short" | "long";
64
+ }
65
+ }
21
66
  }
22
- export interface PluralRulesInternal extends NumberFormatDigitInternalSlots {
23
- initializedPluralRules: boolean;
24
- locale: string;
25
- type: "cardinal" | "ordinal";
26
- notation: "standard" | "compact";
27
- compactDisplay?: "short" | "long";
28
- dataLocaleData?: any;
67
+ interface PluralRulesInternal extends NumberFormatDigitInternalSlots {
68
+ initializedPluralRules: boolean;
69
+ locale: string;
70
+ type: "cardinal" | "ordinal";
71
+ notation: "standard" | "compact";
72
+ compactDisplay?: "short" | "long";
73
+ dataLocaleData?: any;
29
74
  }
30
- export declare class PluralRules {
31
- constructor(locales?: string | string[], options?: Intl.PluralRulesOptions);
32
- resolvedOptions(): Intl.ResolvedPluralRulesOptions;
33
- select(val: number | bigint): LDMLPluralRule;
34
- /**
35
- * Intl.PluralRules.prototype.selectRange ( start, end )
36
- *
37
- * Returns a string indicating which plural rule applies to a range of numbers.
38
- * This is useful for formatting ranges like "1-2 items" vs "2-3 items" where
39
- * different languages have different plural rules for ranges.
40
- *
41
- * Specification: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange
42
- *
43
- * @param start - The start value of the range (number or bigint)
44
- * @param end - The end value of the range (number or bigint)
45
- * @returns The plural category for the range (zero, one, two, few, many, or other)
46
- *
47
- * @example
48
- * const pr = new Intl.PluralRules('en');
49
- * pr.selectRange(1, 2); // "other" (English: "1-2 items")
50
- * pr.selectRange(1, 1); // "one" (same value: "1 item")
51
- *
52
- * @example
53
- * const prFr = new Intl.PluralRules('fr');
54
- * prFr.selectRange(0, 1); // "one" (French: "0-1 vue")
55
- * prFr.selectRange(1, 2); // "other" (French: "1-2 vues")
56
- *
57
- * @example
58
- * // BigInt support (spec-compliant, but Chrome has a bug as of early 2025)
59
- * pr.selectRange(BigInt(1), BigInt(2)); // "other"
60
- *
61
- * @throws {TypeError} If start or end is undefined
62
- * @throws {RangeError} If start or end is not a finite number (Infinity, NaN)
63
- *
64
- * @note Chrome's native implementation (as of early 2025) has a bug where it throws
65
- * "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
66
- * a browser bug - the spec requires BigInt support. This polyfill handles BigInt correctly.
67
- */
68
- selectRange(start: number | bigint, end: number | bigint): LDMLPluralRule;
69
- toString(): string;
70
- static supportedLocalesOf(locales?: string | string[], options?: Pick<Intl.PluralRulesOptions, "localeMatcher">): string[];
71
- static __addLocaleData(...data: PluralRulesLocaleData[]): void;
72
- static localeData: Record<string, PluralRulesData>;
73
- static availableLocales: Set<string>;
74
- static __defaultLocale: string;
75
- static getDefaultLocale(): string;
76
- static relevantExtensionKeys: never[];
77
- static polyfilled: boolean;
75
+ declare class PluralRules {
76
+ constructor(locales?: string | string[], options?: Intl.PluralRulesOptions);
77
+ resolvedOptions(): Intl.ResolvedPluralRulesOptions;
78
+ select(val: number | bigint): LDMLPluralRule;
79
+ /**
80
+ * Intl.PluralRules.prototype.selectRange ( start, end )
81
+ *
82
+ * Returns a string indicating which plural rule applies to a range of numbers.
83
+ * This is useful for formatting ranges like "1-2 items" vs "2-3 items" where
84
+ * different languages have different plural rules for ranges.
85
+ *
86
+ * Specification: https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange
87
+ *
88
+ * @param start - The start value of the range (number or bigint)
89
+ * @param end - The end value of the range (number or bigint)
90
+ * @returns The plural category for the range (zero, one, two, few, many, or other)
91
+ *
92
+ * @example
93
+ * const pr = new Intl.PluralRules('en');
94
+ * pr.selectRange(1, 2); // "other" (English: "1-2 items")
95
+ * pr.selectRange(1, 1); // "one" (same value: "1 item")
96
+ *
97
+ * @example
98
+ * const prFr = new Intl.PluralRules('fr');
99
+ * prFr.selectRange(0, 1); // "one" (French: "0-1 vue")
100
+ * prFr.selectRange(1, 2); // "other" (French: "1-2 vues")
101
+ *
102
+ * @example
103
+ * // BigInt support (spec-compliant, but Chrome has a bug as of early 2025)
104
+ * pr.selectRange(BigInt(1), BigInt(2)); // "other"
105
+ *
106
+ * @throws {TypeError} If start or end is undefined
107
+ * @throws {RangeError} If start or end is not a finite number (Infinity, NaN)
108
+ *
109
+ * @note Chrome's native implementation (as of early 2025) has a bug where it throws
110
+ * "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
111
+ * a browser bug - the spec requires BigInt support. This polyfill handles BigInt correctly.
112
+ */
113
+ selectRange(start: number | bigint, end: number | bigint): LDMLPluralRule;
114
+ toString(): string;
115
+ static supportedLocalesOf(locales?: string | string[], options?: Pick<Intl.PluralRulesOptions, "localeMatcher">): string[];
116
+ static __addLocaleData(...data: PluralRulesLocaleData[]): void;
117
+ static localeData: Record<string, PluralRulesData>;
118
+ static availableLocales: Set<string>;
119
+ static __defaultLocale: string;
120
+ static getDefaultLocale(): string;
121
+ static relevantExtensionKeys: never[];
122
+ static polyfilled: boolean;
78
123
  }
124
+ //#endregion
125
+ export { PluralRules, PluralRulesInternal };
126
+ //# sourceMappingURL=index.d.ts.map