Skip to content

Commit ae70bb7

Browse files
feat: Intl.PluralRules
1 parent 04a426b commit ae70bb7

File tree

4 files changed

+64
-8
lines changed

4 files changed

+64
-8
lines changed

bsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
{
1010
"dir": "test",
11+
"subdirs": ["intl"],
1112
"type": "dev"
1213
}
1314
],

src/intl/Core__Intl__PluralRules.res

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,76 @@
11
type t
22

3+
type localeType = [#cardinal | #ordinal]
4+
5+
type options = {
6+
localeMatcher?: Core__Intl__Common.localeMatcher,
7+
\"type"?: localeType,
8+
// use either this group
9+
minimumIntegerDigits?: Core__Intl__Common.oneTo21,
10+
minimumFractionDigits?: Core__Intl__Common.zeroTo20,
11+
maximumFractionDigits?: Core__Intl__Common.zeroTo20,
12+
// OR this group
13+
minimumSignificantDigits?: Core__Intl__Common.oneTo21,
14+
maximumSignificantDigits?: Core__Intl__Common.oneTo21,
15+
}
16+
17+
type pluralCategories = [
18+
| #zero
19+
| #one
20+
| #two
21+
| #few
22+
| #many
23+
| #other
24+
]
25+
26+
type resolvedOptions = {
27+
locale: string,
28+
pluralCategories: array<pluralCategories>,
29+
\"type": localeType,
30+
// either this group
31+
minimumIntegerDigits?: Core__Intl__Common.oneTo21,
32+
minimumFractionDigits?: Core__Intl__Common.zeroTo20,
33+
maximumFractionDigits?: Core__Intl__Common.zeroTo20,
34+
// OR this group
35+
minimumSignificantDigits?: Core__Intl__Common.oneTo21,
36+
maximumSignificantDigits?: Core__Intl__Common.oneTo21,
37+
}
38+
39+
type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher}
40+
341
@new external make: unit => t = "Intl.PluralRules"
442
@new external makeWithLocale: string => t = "Intl.PluralRules"
543
@new external makeWithLocales: array<string> => t = "Intl.PluralRules"
6-
@new external makeWithLocaleAndOptions: (string, {..}) => t = "Intl.PluralRules"
7-
@new external makeWithLocalesAndOptions: (array<string>, {..}) => t = "Intl.PluralRules"
8-
@new external makeWithOptions: (@as(json`undefined`) _, {..}) => t = "Intl.PluralRules"
44+
@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.PluralRules"
45+
@new external makeWithLocalesAndOptions: (array<string>, options) => t = "Intl.PluralRules"
46+
@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.PluralRules"
947

1048
@val external supportedLocalesOf: array<string> => t = "Intl.PluralRules.supportedLocalesOf"
1149
@val
12-
external supportedLocalesOfWithOptions: (array<string>, {..}) => t =
50+
external supportedLocalesOfWithOptions: (array<string>, supportedLocalesOptions) => t =
1351
"Intl.PluralRules.supportedLocalesOf"
1452

15-
@send external resolvedOptions: t => {..} = "resolvedOptions"
53+
@send external resolvedOptions: t => resolvedOptions = "resolvedOptions"
1654

1755
type rule = [#zero | #one | #two | #few | #many | #other]
1856

1957
@send external select: (t, float) => rule = "select"
2058
@send external selectInt: (t, int) => rule = "select"
2159
@send external selectBigInt: (t, Core__BigInt.t) => rule = "select"
60+
61+
/**
62+
Not supported in Firefox v110
63+
*/
64+
@send
65+
external selectRange: (t, ~start: float, ~end: float) => rule = "selectRange"
66+
/**
67+
Not supported in Firefox v110
68+
*/
69+
@send
70+
external selectRangeInt: (t, ~start: int, ~end: int) => rule = "selectRange"
71+
/**
72+
Not supported in Firefox v110
73+
*/
74+
@send
75+
external selectRangeBigInt: (t, ~start: Core__BigInt.t, ~end: Core__BigInt.t) => rule =
76+
"selectRange"

test/ArrayTests.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ Test.run([
450450
Test.run([
451451
[
452452
"ArrayTests.res",
453-
109,
453+
112,
454454
20,
455455
39
456456
],
@@ -464,7 +464,7 @@ Test.run([
464464
Test.run([
465465
[
466466
"ArrayTests.res",
467-
110,
467+
113,
468468
20,
469469
34
470470
],

test/TempTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

33
import * as Core__Int from "../src/Core__Int.mjs";
4-
import * as IntlTests from "./Intl/IntlTests.mjs";
4+
import * as IntlTests from "./intl/IntlTests.mjs";
55
import * as Core__Dict from "../src/Core__Dict.mjs";
66
import * as Core__JSON from "../src/Core__JSON.mjs";
77
import * as Caml_option from "rescript/lib/es6/caml_option.js";

0 commit comments

Comments
 (0)