@formatjs/intl-pluralrules 6.4.0 → 7.0.1

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/locale-data/af.js CHANGED
@@ -1,13 +1,24 @@
1
1
  /* @generated */
2
2
  // prettier-ignore
3
3
  if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
- Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["few","other"]},"fn":function(num, isOrdinal, exponent = 0) {
5
+ function modDigits(digits, divisor) {
6
+ let value = 0;
7
+ for (let index = 0; index < digits.length; index++) {
8
+ const digit = digits.charCodeAt(index) - 48;
9
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
10
+ }
11
+ return value;
12
+ }
5
13
  const numStr = String(num);
6
14
  const parts = numStr.split(".");
7
15
  const integerPart = parts[0];
8
16
  const decimalPart = parts[1] || "";
9
17
  const n = Math.abs(parseFloat(numStr));
18
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
10
19
  if (isOrdinal) {
20
+ if ((modDigits(integerPart, 100) >= 2 && modDigits(integerPart, 100) <= 19))
21
+ return "few";
11
22
  }
12
23
  else {
13
24
  if ((!/[1-9]/.test(decimalPart) && n === 1))
@@ -16,13 +27,24 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
16
27
  return "other";
17
28
  },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"other","other_other":"other"},"ordinal":{}}},"locale":"af"})
18
29
  } else {
19
- (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
30
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["few","other"]},"fn":function(num, isOrdinal, exponent = 0) {
31
+ function modDigits(digits, divisor) {
32
+ let value = 0;
33
+ for (let index = 0; index < digits.length; index++) {
34
+ const digit = digits.charCodeAt(index) - 48;
35
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
36
+ }
37
+ return value;
38
+ }
20
39
  const numStr = String(num);
21
40
  const parts = numStr.split(".");
22
41
  const integerPart = parts[0];
23
42
  const decimalPart = parts[1] || "";
24
43
  const n = Math.abs(parseFloat(numStr));
44
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
25
45
  if (isOrdinal) {
46
+ if ((modDigits(integerPart, 100) >= 2 && modDigits(integerPart, 100) <= 19))
47
+ return "few";
26
48
  }
27
49
  else {
28
50
  if ((!/[1-9]/.test(decimalPart) && n === 1))
package/locale-data/bg.js CHANGED
@@ -1,13 +1,28 @@
1
1
  /* @generated */
2
2
  // prettier-ignore
3
3
  if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
- Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["few","one","other","two"]},"fn":function(num, isOrdinal, exponent = 0) {
5
+ function modDigits(digits, divisor) {
6
+ let value = 0;
7
+ for (let index = 0; index < digits.length; index++) {
8
+ const digit = digits.charCodeAt(index) - 48;
9
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
10
+ }
11
+ return value;
12
+ }
5
13
  const numStr = String(num);
6
14
  const parts = numStr.split(".");
7
15
  const integerPart = parts[0];
8
16
  const decimalPart = parts[1] || "";
9
17
  const n = Math.abs(parseFloat(numStr));
18
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
10
19
  if (isOrdinal) {
20
+ if (modDigits(integerPart, 10) === 1 && modDigits(integerPart, 100) !== 11)
21
+ return "one";
22
+ if (modDigits(integerPart, 10) === 2 && modDigits(integerPart, 100) !== 12)
23
+ return "two";
24
+ if ((modDigits(integerPart, 10) === 3 || modDigits(integerPart, 10) === 4) && (modDigits(integerPart, 100) !== 13 && modDigits(integerPart, 100) !== 14))
25
+ return "few";
11
26
  }
12
27
  else {
13
28
  if ((!/[1-9]/.test(decimalPart) && n === 1))
@@ -16,13 +31,28 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
16
31
  return "other";
17
32
  },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"other","other_other":"other"},"ordinal":{}}},"locale":"bg"})
18
33
  } else {
19
- (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
34
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["few","one","other","two"]},"fn":function(num, isOrdinal, exponent = 0) {
35
+ function modDigits(digits, divisor) {
36
+ let value = 0;
37
+ for (let index = 0; index < digits.length; index++) {
38
+ const digit = digits.charCodeAt(index) - 48;
39
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
40
+ }
41
+ return value;
42
+ }
20
43
  const numStr = String(num);
21
44
  const parts = numStr.split(".");
22
45
  const integerPart = parts[0];
23
46
  const decimalPart = parts[1] || "";
24
47
  const n = Math.abs(parseFloat(numStr));
48
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
25
49
  if (isOrdinal) {
50
+ if (modDigits(integerPart, 10) === 1 && modDigits(integerPart, 100) !== 11)
51
+ return "one";
52
+ if (modDigits(integerPart, 10) === 2 && modDigits(integerPart, 100) !== 12)
53
+ return "two";
54
+ if ((modDigits(integerPart, 10) === 3 || modDigits(integerPart, 10) === 4) && (modDigits(integerPart, 100) !== 13 && modDigits(integerPart, 100) !== 14))
55
+ return "few";
26
56
  }
27
57
  else {
28
58
  if ((!/[1-9]/.test(decimalPart) && n === 1))
package/locale-data/es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* @generated */
2
2
  // prettier-ignore
3
3
  if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
- Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["other"]},"compactExponents":{"short":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":6,"10":9,"11":9,"12":12,"13":12,"14":12},"long":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":9,"10":9,"11":9,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["one","other"]},"compactExponents":{"short":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":6,"10":9,"11":9,"12":12,"13":12,"14":12},"long":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":9,"10":9,"11":9,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
5
5
  function modDigits(digits, divisor) {
6
6
  let value = 0;
7
7
  for (let index = 0; index < digits.length; index++) {
@@ -19,6 +19,8 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
19
19
  const v = decimalPart.length;
20
20
  const e = exponent;
21
21
  if (isOrdinal) {
22
+ if ((!/[1-9]/.test(decimalPart) && (modDigits(integerPart, 10) === 1 || modDigits(integerPart, 10) === 3)) && (/[1-9]/.test(decimalPart) || modDigits(integerPart, 100) !== 11))
23
+ return "one";
22
24
  }
23
25
  else {
24
26
  if ((!/[1-9]/.test(decimalPart) && n === 1))
@@ -29,7 +31,7 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
29
31
  return "other";
30
32
  },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"other","other_other":"other"},"ordinal":{}}},"locale":"es"})
31
33
  } else {
32
- (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["other"]},"compactExponents":{"short":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":6,"10":9,"11":9,"12":12,"13":12,"14":12},"long":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":9,"10":9,"11":9,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
34
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["one","other"]},"compactExponents":{"short":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":6,"10":9,"11":9,"12":12,"13":12,"14":12},"long":{"3":3,"4":3,"5":3,"6":6,"7":6,"8":6,"9":9,"10":9,"11":9,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
33
35
  function modDigits(digits, divisor) {
34
36
  let value = 0;
35
37
  for (let index = 0; index < digits.length; index++) {
@@ -47,6 +49,8 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
47
49
  const v = decimalPart.length;
48
50
  const e = exponent;
49
51
  if (isOrdinal) {
52
+ if ((!/[1-9]/.test(decimalPart) && (modDigits(integerPart, 10) === 1 || modDigits(integerPart, 10) === 3)) && (/[1-9]/.test(decimalPart) || modDigits(integerPart, 100) !== 11))
53
+ return "one";
50
54
  }
51
55
  else {
52
56
  if ((!/[1-9]/.test(decimalPart) && n === 1))
package/locale-data/fr.js CHANGED
@@ -23,7 +23,7 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
23
23
  return "one";
24
24
  }
25
25
  else {
26
- if ((i === 0 || i === 1))
26
+ if ((i >= 0 && i <= 1))
27
27
  return "one";
28
28
  if (e === 0 && i !== 0 && modDigits(integerPart, 1000000) === 0 && v === 0 || (e < 0 || e > 5))
29
29
  return "many";
@@ -53,7 +53,7 @@ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function')
53
53
  return "one";
54
54
  }
55
55
  else {
56
- if ((i === 0 || i === 1))
56
+ if ((i >= 0 && i <= 1))
57
57
  return "one";
58
58
  if (e === 0 && i !== 0 && modDigits(integerPart, 1000000) === 0 && v === 0 || (e < 0 || e > 5))
59
59
  return "many";
package/locale-data/gl.js CHANGED
@@ -1,34 +1,56 @@
1
1
  /* @generated */
2
2
  // prettier-ignore
3
3
  if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
- Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["other"]},"compactExponents":{"short":{"3":0,"4":0,"5":0,"6":6,"7":6,"8":6,"9":6,"10":6,"11":6,"12":12,"13":12,"14":12},"long":{"3":0,"4":0,"5":0,"6":6,"7":6,"8":6,"9":6,"10":6,"11":6,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
5
+ function modDigits(digits, divisor) {
6
+ let value = 0;
7
+ for (let index = 0; index < digits.length; index++) {
8
+ const digit = digits.charCodeAt(index) - 48;
9
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
10
+ }
11
+ return value;
12
+ }
5
13
  const numStr = String(num);
6
14
  const parts = numStr.split(".");
7
15
  const integerPart = parts[0];
8
16
  const decimalPart = parts[1] || "";
9
17
  const i = Math.floor(Math.abs(parseFloat(integerPart)));
10
18
  const v = decimalPart.length;
19
+ const e = exponent;
11
20
  if (isOrdinal) {
12
21
  }
13
22
  else {
14
23
  if (i === 1 && v === 0)
15
24
  return "one";
25
+ if (e === 0 && i !== 0 && modDigits(integerPart, 1000000) === 0 && v === 0 || (e < 0 || e > 5))
26
+ return "many";
16
27
  }
17
28
  return "other";
18
29
  },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"gl"})
19
30
  } else {
20
- (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
31
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["many","one","other"],"ordinal":["other"]},"compactExponents":{"short":{"3":0,"4":0,"5":0,"6":6,"7":6,"8":6,"9":6,"10":6,"11":6,"12":12,"13":12,"14":12},"long":{"3":0,"4":0,"5":0,"6":6,"7":6,"8":6,"9":6,"10":6,"11":6,"12":12,"13":12,"14":12}},"fn":function(num, isOrdinal, exponent = 0) {
32
+ function modDigits(digits, divisor) {
33
+ let value = 0;
34
+ for (let index = 0; index < digits.length; index++) {
35
+ const digit = digits.charCodeAt(index) - 48;
36
+ if (digit >= 0 && digit <= 9) value = (value * 10 + digit) % divisor;
37
+ }
38
+ return value;
39
+ }
21
40
  const numStr = String(num);
22
41
  const parts = numStr.split(".");
23
42
  const integerPart = parts[0];
24
43
  const decimalPart = parts[1] || "";
25
44
  const i = Math.floor(Math.abs(parseFloat(integerPart)));
26
45
  const v = decimalPart.length;
46
+ const e = exponent;
27
47
  if (isOrdinal) {
28
48
  }
29
49
  else {
30
50
  if (i === 1 && v === 0)
31
51
  return "one";
52
+ if (e === 0 && i !== 0 && modDigits(integerPart, 1000000) === 0 && v === 0 || (e < 0 || e > 5))
53
+ return "many";
32
54
  }
33
55
  return "other";
34
56
  },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"gl"})
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,35 @@
1
+ /* @generated */
2
+ // prettier-ignore
3
+ if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
5
+ const numStr = String(num);
6
+ const parts = numStr.split(".");
7
+ const integerPart = parts[0];
8
+ const decimalPart = parts[1] || "";
9
+ const n = Math.abs(parseFloat(numStr));
10
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
11
+ if (isOrdinal) {
12
+ }
13
+ else {
14
+ if (i === 0 || (!/[1-9]/.test(decimalPart) && n === 1))
15
+ return "one";
16
+ }
17
+ return "other";
18
+ },"pluralRanges":{"cardinal":{"one_one":"other","one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"tg"})
19
+ } else {
20
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["other"]},"fn":function(num, isOrdinal, exponent = 0) {
21
+ const numStr = String(num);
22
+ const parts = numStr.split(".");
23
+ const integerPart = parts[0];
24
+ const decimalPart = parts[1] || "";
25
+ const n = Math.abs(parseFloat(numStr));
26
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
27
+ if (isOrdinal) {
28
+ }
29
+ else {
30
+ if (i === 0 || (!/[1-9]/.test(decimalPart) && n === 1))
31
+ return "one";
32
+ }
33
+ return "other";
34
+ },"pluralRanges":{"cardinal":{"one_one":"other","one_other":"other","other_one":"one","other_other":"other"},"ordinal":{}}},"locale":"tg"})
35
+ }
package/locale-data/vi.js CHANGED
@@ -1,33 +1,39 @@
1
1
  /* @generated */
2
2
  // prettier-ignore
3
3
  if (Intl.PluralRules && typeof Intl.PluralRules.__addLocaleData === 'function') {
4
- Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["other"],"ordinal":["one","other"]},"fn":function(num, isOrdinal, exponent = 0) {
4
+ Intl.PluralRules.__addLocaleData({"data":{"categories":{"cardinal":["one","other"],"ordinal":["one","other"]},"fn":function(num, isOrdinal, exponent = 0) {
5
5
  const numStr = String(num);
6
6
  const parts = numStr.split(".");
7
7
  const integerPart = parts[0];
8
8
  const decimalPart = parts[1] || "";
9
9
  const n = Math.abs(parseFloat(numStr));
10
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
10
11
  if (isOrdinal) {
11
12
  if ((!/[1-9]/.test(decimalPart) && n === 1))
12
13
  return "one";
13
14
  }
14
15
  else {
16
+ if (i === 0 || (!/[1-9]/.test(decimalPart) && n === 1))
17
+ return "one";
15
18
  }
16
19
  return "other";
17
- },"pluralRanges":{"cardinal":{"other_other":"other"},"ordinal":{}}},"locale":"vi"})
20
+ },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"other","other_other":"other"},"ordinal":{}}},"locale":"vi"})
18
21
  } else {
19
- (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["other"],"ordinal":["one","other"]},"fn":function(num, isOrdinal, exponent = 0) {
22
+ (globalThis.__FORMATJS_PLURALRULES_DATA__ = globalThis.__FORMATJS_PLURALRULES_DATA__ || []).push({"data":{"categories":{"cardinal":["one","other"],"ordinal":["one","other"]},"fn":function(num, isOrdinal, exponent = 0) {
20
23
  const numStr = String(num);
21
24
  const parts = numStr.split(".");
22
25
  const integerPart = parts[0];
23
26
  const decimalPart = parts[1] || "";
24
27
  const n = Math.abs(parseFloat(numStr));
28
+ const i = Math.floor(Math.abs(parseFloat(integerPart)));
25
29
  if (isOrdinal) {
26
30
  if ((!/[1-9]/.test(decimalPart) && n === 1))
27
31
  return "one";
28
32
  }
29
33
  else {
34
+ if (i === 0 || (!/[1-9]/.test(decimalPart) && n === 1))
35
+ return "one";
30
36
  }
31
37
  return "other";
32
- },"pluralRanges":{"cardinal":{"other_other":"other"},"ordinal":{}}},"locale":"vi"})
38
+ },"pluralRanges":{"cardinal":{"one_other":"other","other_one":"other","other_other":"other"},"ordinal":{}}},"locale":"vi"})
33
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-pluralrules",
3
- "version": "6.4.0",
3
+ "version": "7.0.1",
4
4
  "description": "Polyfill for Intl.PluralRules",
5
5
  "keywords": [
6
6
  "PluralRules",
@@ -29,7 +29,7 @@
29
29
  "./should-polyfill.js": "./should-polyfill.js"
30
30
  },
31
31
  "dependencies": {
32
- "@formatjs/bigdecimal": "0.2.7",
33
- "@formatjs/intl-localematcher": "0.10.0"
32
+ "@formatjs/bigdecimal": "0.2.9",
33
+ "@formatjs/intl-localematcher": "0.10.1"
34
34
  }
35
35
  }