diff --git a/CHANGELOG.md b/CHANGELOG.md index eb5088e5..23039663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next version +- BREAKING: Intl types: simplify bindings for constructors / functions with optional arguments. https://github.com/rescript-association/rescript-core/pull/198 - Fix: Expose Intl.Common. https://github.com/rescript-association/rescript-core/pull/197 - Add `Array.flatMapWithIndex` https://github.com/rescript-association/rescript-core/pull/199 diff --git a/src/intl/Core__Intl__Collator.res b/src/intl/Core__Intl__Collator.res index 300b8766..a6271c57 100644 --- a/src/intl/Core__Intl__Collator.res +++ b/src/intl/Core__Intl__Collator.res @@ -25,16 +25,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.Collator" -@new external makeWithLocale: string => t = "Intl.Collator" -@new external makeWithLocales: array => t = "Intl.Collator" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Collator" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.Collator" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Collator" - -@val external supportedLocalesOf: array => t = "Intl.Collator.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Collator" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.Collator.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__DateTimeFormat.res b/src/intl/Core__Intl__DateTimeFormat.res index 009445e3..1ec24b29 100644 --- a/src/intl/Core__Intl__DateTimeFormat.res +++ b/src/intl/Core__Intl__DateTimeFormat.res @@ -105,16 +105,10 @@ type dateTimeRangePart = { source: dateTimeRangeSource, } -@new external make: unit => t = "Intl.DateTimeFormat" -@new external makeWithLocale: string => t = "Intl.DateTimeFormat" -@new external makeWithLocales: array => t = "Intl.DateTimeFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.DateTimeFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.DateTimeFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.DateTimeFormat" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.DateTimeFormat" -@val external supportedLocalesOf: array => t = "Intl.DateTimeFormat.supportedLocalesOf" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.DateTimeFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__ListFormat.res b/src/intl/Core__Intl__ListFormat.res index 43a6174a..ba728899 100644 --- a/src/intl/Core__Intl__ListFormat.res +++ b/src/intl/Core__Intl__ListFormat.res @@ -35,16 +35,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.ListFormat" -@new external makeWithLocale: string => t = "Intl.ListFormat" -@new external makeWithLocales: array => t = "Intl.ListFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.ListFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.ListFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.ListFormat" - -@val external supportedLocalesOf: array => t = "Intl.ListFormat.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.ListFormat" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.ListFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__Locale.res b/src/intl/Core__Intl__Locale.res index 5d6afb47..07d32332 100644 --- a/src/intl/Core__Intl__Locale.res +++ b/src/intl/Core__Intl__Locale.res @@ -13,8 +13,7 @@ type options = { region?: string, } -@new external make: string => t = "Intl.Locale" -@new external makeWithOptions: (string, options) => t = "Intl.Locale" +@new external make: (string, ~options: options=?) => t = "Intl.Locale" @get external baseName: t => string = "baseName" @get external calendar: t => option = "calendar" diff --git a/src/intl/Core__Intl__NumberFormat.res b/src/intl/Core__Intl__NumberFormat.res index f229a3f5..3929e8cf 100644 --- a/src/intl/Core__Intl__NumberFormat.res +++ b/src/intl/Core__Intl__NumberFormat.res @@ -166,17 +166,10 @@ type numberFormatRangePart = { source: rangeSource, } -@new external make: unit => t = "Intl.NumberFormat" -@new external makeWithLocale: string => t = "Intl.NumberFormat" -@new external makeWithLocales: array => t = "Intl.NumberFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.NumberFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.NumberFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.NumberFormat" - -@val external supportedLocalesOf: array => t = "Intl.NumberFormat.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.NumberFormat" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.NumberFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__PluralRules.res b/src/intl/Core__Intl__PluralRules.res index 008f5ab3..7831df0a 100644 --- a/src/intl/Core__Intl__PluralRules.res +++ b/src/intl/Core__Intl__PluralRules.res @@ -38,16 +38,10 @@ type resolvedOptions = { type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.PluralRules" -@new external makeWithLocale: string => t = "Intl.PluralRules" -@new external makeWithLocales: array => t = "Intl.PluralRules" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.PluralRules" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.PluralRules" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.PluralRules" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.PluralRules" -@val external supportedLocalesOf: array => t = "Intl.PluralRules.supportedLocalesOf" @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.PluralRules.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__RelativeTimeFormat.res b/src/intl/Core__Intl__RelativeTimeFormat.res index 8cbf2138..97849049 100644 --- a/src/intl/Core__Intl__RelativeTimeFormat.res +++ b/src/intl/Core__Intl__RelativeTimeFormat.res @@ -26,17 +26,11 @@ type relativeTimePart = { unit?: timeUnit, } -@new external make: unit => t = "Intl.RelativeTimeFormat" -@new external makeWithLocale: string => t = "Intl.RelativeTimeFormat" -@new external makeWithLocales: array => t = "Intl.RelativeTimeFormat" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.RelativeTimeFormat" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.RelativeTimeFormat" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.RelativeTimeFormat" +@new +external make: (~locales: array=?, ~options: options=?) => t = "Intl.RelativeTimeFormat" @val -external supportedLocalesOf: array => t = "Intl.RelativeTimeFormat.supportedLocalesOf" -@val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.RelativeTimeFormat.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/src/intl/Core__Intl__Segmenter.res b/src/intl/Core__Intl__Segmenter.res index c6def395..e99b576d 100644 --- a/src/intl/Core__Intl__Segmenter.res +++ b/src/intl/Core__Intl__Segmenter.res @@ -23,16 +23,10 @@ type resolvedOptions = {locale: string, granularity: granularity} type supportedLocalesOptions = {localeMatcher: Core__Intl__Common.localeMatcher} -@new external make: unit => t = "Intl.Segmenter" -@new external makeWithLocale: string => t = "Intl.Segmenter" -@new external makeWithLocales: array => t = "Intl.Segmenter" -@new external makeWithLocaleAndOptions: (string, options) => t = "Intl.Segmenter" -@new external makeWithLocalesAndOptions: (array, options) => t = "Intl.Segmenter" -@new external makeWithOptions: (@as(json`undefined`) _, options) => t = "Intl.Segmenter" - -@val external supportedLocalesOf: array => t = "Intl.Segmenter.supportedLocalesOf" +@new external make: (~locales: array=?, ~options: options=?) => t = "Intl.Segmenter" + @val -external supportedLocalesOfWithOptions: (array, supportedLocalesOptions) => t = +external supportedLocalesOf: (array, ~options: supportedLocalesOptions=?) => t = "Intl.Segmenter.supportedLocalesOf" @send external resolvedOptions: t => resolvedOptions = "resolvedOptions" diff --git a/test/intl/Intl__CollatorTest.mjs b/test/intl/Intl__CollatorTest.mjs index 3945f3a8..a42c8e08 100644 --- a/test/intl/Intl__CollatorTest.mjs +++ b/test/intl/Intl__CollatorTest.mjs @@ -5,16 +5,16 @@ console.log("---"); console.log("Intl.Collator"); -new Intl.Collator(); +new Intl.Collator(undefined, undefined); -new Intl.Collator("en-US"); +new Intl.Collator(["en-US"], undefined); var _collator = new Intl.Collator([ "en-US", "en-GB" - ]); + ], undefined); -var collator = new Intl.Collator("en-US", { +var collator = new Intl.Collator(["en-US"], { sensitivity: "base", ignorePunctuation: true, numeric: true, @@ -24,7 +24,7 @@ var collator = new Intl.Collator("en-US", { Intl.Collator.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.Collator.supportedLocalesOf([ "en-US", @@ -37,7 +37,7 @@ console.log(collator.resolvedOptions()); console.log(collator.compare("hi", "hï")); -console.log(Intl.Collator.supportedLocalesOf(["hi"])); +console.log(Intl.Collator.supportedLocalesOf(["hi"], undefined)); export { _collator , diff --git a/test/intl/Intl__CollatorTest.res b/test/intl/Intl__CollatorTest.res index 45ea8d7b..abba374f 100644 --- a/test/intl/Intl__CollatorTest.res +++ b/test/intl/Intl__CollatorTest.res @@ -4,14 +4,14 @@ Console.log("---") Console.log("Intl.Collator") let _collator = Intl.Collator.make() -let _collator = Intl.Collator.makeWithLocale("en-US") -let _collator = Intl.Collator.makeWithLocales(["en-US", "en-GB"]) -let collator = Intl.Collator.makeWithLocaleAndOptions( - "en-US", - {caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, +let _collator = Intl.Collator.make(~locales=["en-US"]) +let _collator = Intl.Collator.make(~locales=["en-US", "en-GB"]) +let collator = Intl.Collator.make( + ~locales=["en-US"], + ~options={caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, ) Intl.Collator.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.Collator.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.Collator.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore collator->Intl.Collator.resolvedOptions->Console.log collator->Intl.Collator.compare("hi", "hï")->Console.log diff --git a/test/intl/Intl__DateTimeFormatTest.mjs b/test/intl/Intl__DateTimeFormatTest.mjs index 140ae17c..62e31e91 100644 --- a/test/intl/Intl__DateTimeFormatTest.mjs +++ b/test/intl/Intl__DateTimeFormatTest.mjs @@ -9,7 +9,7 @@ console.log("Intl.DateTimeFormat"); Intl.DateTimeFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.DateTimeFormat.supportedLocalesOf([ "en-US", @@ -77,7 +77,7 @@ var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = console.log(formatter$6.format(new Date(Date.now()))); -var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); +var resolvedOptions = new Intl.DateTimeFormat(undefined, undefined).resolvedOptions(); var timeZone = resolvedOptions.timeZone; diff --git a/test/intl/Intl__DateTimeFormatTest.res b/test/intl/Intl__DateTimeFormatTest.res index f98b75c1..20e77d58 100644 --- a/test/intl/Intl__DateTimeFormatTest.res +++ b/test/intl/Intl__DateTimeFormatTest.res @@ -4,12 +4,12 @@ Console.log("---") Console.log("Intl.DateTimeFormat") Intl.DateTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.DateTimeFormat.supportedLocalesOfWithOptions( +Intl.DateTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], - {localeMatcher: #lookup}, + ~options={localeMatcher: #lookup}, )->ignore -let formatter = Intl.DateTimeFormat.makeWithOptions({dateStyle: #full, timeStyle: #full}) +let formatter = Intl.DateTimeFormat.make(~options={dateStyle: #full, timeStyle: #full}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) @@ -35,23 +35,23 @@ let options: Intl.DateTimeFormat.options = { fractionalSecondDigits: #3, timeZoneName: #longGeneric, } -let formatter = Intl.DateTimeFormat.makeWithOptions(options) +let formatter = Intl.DateTimeFormat.make(~options) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #long}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #long}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #longOffset}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #longOffset}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #short}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #short}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #shortGeneric}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortGeneric}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) -let formatter = Intl.DateTimeFormat.makeWithOptions({...options, timeZoneName: #shortOffset}) +let formatter = Intl.DateTimeFormat.make(~options={...options, timeZoneName: #shortOffset}) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) let resolvedOptions = Intl.DateTimeFormat.make()->Intl.DateTimeFormat.resolvedOptions diff --git a/test/intl/Intl__ListFormatTest.mjs b/test/intl/Intl__ListFormatTest.mjs index 592a5eb7..f4bb15e8 100644 --- a/test/intl/Intl__ListFormatTest.mjs +++ b/test/intl/Intl__ListFormatTest.mjs @@ -5,19 +5,12 @@ console.log("---"); console.log("Intl.ListFormat"); -new Intl.ListFormat(); - -new Intl.ListFormat("en-US"); +new Intl.ListFormat(undefined, undefined); new Intl.ListFormat([ "en-US", "en-GB" - ]); - -new Intl.ListFormat("en-US", { - type: "conjunction", - style: "long" - }); + ], undefined); var _formatter = new Intl.ListFormat([ "en-US", @@ -30,7 +23,7 @@ var _formatter = new Intl.ListFormat([ Intl.ListFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.ListFormat.supportedLocalesOf([ "en-US", diff --git a/test/intl/Intl__ListFormatTest.res b/test/intl/Intl__ListFormatTest.res index 8bb9a479..ec5fae7d 100644 --- a/test/intl/Intl__ListFormatTest.res +++ b/test/intl/Intl__ListFormatTest.res @@ -4,20 +4,15 @@ Console.log("---") Console.log("Intl.ListFormat") let _formatter = Intl.ListFormat.make() -let _formatter = Intl.ListFormat.makeWithLocale("en-US") -let _formatter = Intl.ListFormat.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.ListFormat.makeWithLocaleAndOptions( - "en-US", - {style: #long, \"type": #conjunction}, -) -let _formatter = Intl.ListFormat.makeWithLocalesAndOptions( - ["en-US", "en-GB"], - {style: #long, \"type": #conjunction}, +let _formatter = Intl.ListFormat.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.ListFormat.make( + ~locales=["en-US", "en-GB"], + ~options={style: #long, \"type": #conjunction}, ) Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.ListFormat.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore -let formatter = Intl.ListFormat.makeWithOptions({style: #long, \"type": #conjunction}) +let formatter = Intl.ListFormat.make(~options={style: #long, \"type": #conjunction}) formatter->Intl.ListFormat.resolvedOptions->Console.log formatter->Intl.ListFormat.format(["one", "two", "three"])->Console.log diff --git a/test/intl/Intl__LocaleTest.mjs b/test/intl/Intl__LocaleTest.mjs index a8349a84..f58897c3 100644 --- a/test/intl/Intl__LocaleTest.mjs +++ b/test/intl/Intl__LocaleTest.mjs @@ -5,7 +5,7 @@ console.log("---"); console.log("Intl.Locale"); -var _locale = new Intl.Locale("en-US"); +var _locale = new Intl.Locale("en-US", undefined); var locale = new Intl.Locale("en-US", { calendar: "hebrew", diff --git a/test/intl/Intl__LocaleTest.res b/test/intl/Intl__LocaleTest.res index 543d8004..b91e5001 100644 --- a/test/intl/Intl__LocaleTest.res +++ b/test/intl/Intl__LocaleTest.res @@ -4,9 +4,9 @@ Console.log("---") Console.log("Intl.Locale") let _locale = Intl.Locale.make("en-US") -let locale = Intl.Locale.makeWithOptions( +let locale = Intl.Locale.make( "en-US", - { + ~options={ calendar: #hebrew, collation: #compat, hourCycle: #h24, diff --git a/test/intl/Intl__NumberFormatTest.mjs b/test/intl/Intl__NumberFormatTest.mjs index d19804e9..9f8e02d9 100644 --- a/test/intl/Intl__NumberFormatTest.mjs +++ b/test/intl/Intl__NumberFormatTest.mjs @@ -7,7 +7,7 @@ console.log("---"); console.log("Intl.NumberFormat"); -var currencyFormatter = new Intl.NumberFormat("fr-FR", { +var currencyFormatter = new Intl.NumberFormat(["fr-FR"], { currency: "EUR", style: "currency" }); @@ -15,7 +15,7 @@ var currencyFormatter = new Intl.NumberFormat("fr-FR", { console.log(Intl.NumberFormat.supportedLocalesOf([ "fr-FR", "en-US" - ])); + ], undefined)); console.log(currencyFormatter.format(123.23)); diff --git a/test/intl/Intl__NumberFormatTest.res b/test/intl/Intl__NumberFormatTest.res index 51829077..b6c1595f 100644 --- a/test/intl/Intl__NumberFormatTest.res +++ b/test/intl/Intl__NumberFormatTest.res @@ -3,34 +3,42 @@ open RescriptCore Console.log("---") Console.log("Intl.NumberFormat") -let currencyFormatter = Intl.NumberFormat.makeWithLocaleAndOptions( - "fr-FR", - {currency: "EUR", style: #currency}, +let currencyFormatter = Intl.NumberFormat.make( + ~locales=["fr-FR"], + ~options={currency: "EUR", style: #currency}, ) Console.log(Intl.NumberFormat.supportedLocalesOf(["fr-FR", "en-US"])) Console.log(currencyFormatter->Intl.NumberFormat.format(123.23)) -let roundingFormatter = Intl.NumberFormat.makeWithOptions({ - roundingIncrement: #500, - minimumFractionDigits: #2, - maximumFractionDigits: #2, -}) +let roundingFormatter = Intl.NumberFormat.make( + ~options={ + roundingIncrement: #500, + minimumFractionDigits: #2, + maximumFractionDigits: #2, + }, +) -let groupingFormatter1 = Intl.NumberFormat.makeWithOptions({ - useGrouping: Intl.NumberFormat.Grouping.fromBool(true), -}) -let groupingFormatter2 = Intl.NumberFormat.makeWithOptions({ - useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), -}) +let groupingFormatter1 = Intl.NumberFormat.make( + ~options={ + useGrouping: Intl.NumberFormat.Grouping.fromBool(true), + }, +) +let groupingFormatter2 = Intl.NumberFormat.make( + ~options={ + useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), + }, +) -let sigFormatter = Intl.NumberFormat.makeWithOptions({ - minimumIntegerDigits: #1, - minimumFractionDigits: #1, - maximumFractionDigits: #1, - minimumSignificantDigits: #1, - maximumSignificantDigits: #1, -}) +let sigFormatter = Intl.NumberFormat.make( + ~options={ + minimumIntegerDigits: #1, + minimumFractionDigits: #1, + maximumFractionDigits: #1, + minimumSignificantDigits: #1, + maximumSignificantDigits: #1, + }, +) let options = sigFormatter->Intl.NumberFormat.resolvedOptions Console.log(options) diff --git a/test/intl/Intl__PluralRulesTest.mjs b/test/intl/Intl__PluralRulesTest.mjs index b4fe8030..786eb15a 100644 --- a/test/intl/Intl__PluralRulesTest.mjs +++ b/test/intl/Intl__PluralRulesTest.mjs @@ -5,22 +5,14 @@ console.log("---"); console.log("Intl.PluralRules"); -new Intl.PluralRules(); - -new Intl.PluralRules("en-US"); +new Intl.PluralRules(undefined, undefined); new Intl.PluralRules([ "en-US", "en-GB" - ]); - -new Intl.PluralRules(undefined, { - type: "ordinal", - minimumSignificantDigits: 3, - maximumSignificantDigits: 5 - }); + ], undefined); -var _formatter = new Intl.PluralRules("en-US", { +var _formatter = new Intl.PluralRules(undefined, { type: "ordinal", minimumSignificantDigits: 3, maximumSignificantDigits: 5 diff --git a/test/intl/Intl__PluralRulesTest.res b/test/intl/Intl__PluralRulesTest.res index 4f56404c..30710414 100644 --- a/test/intl/Intl__PluralRulesTest.res +++ b/test/intl/Intl__PluralRulesTest.res @@ -4,24 +4,17 @@ Console.log("---") Console.log("Intl.PluralRules") let _formatter = Intl.PluralRules.make() -let _formatter = Intl.PluralRules.makeWithLocale("en-US") -let _formatter = Intl.PluralRules.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.PluralRules.makeWithOptions({ - \"type": #ordinal, - maximumSignificantDigits: #5, - minimumSignificantDigits: #3, -}) -let _formatter = Intl.PluralRules.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.PluralRules.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.PluralRules.make( + ~options={ \"type": #ordinal, maximumSignificantDigits: #5, minimumSignificantDigits: #3, }, ) -let formatter = Intl.PluralRules.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.PluralRules.make( + ~locales=["en-US"], + ~options={ \"type": #ordinal, maximumSignificantDigits: #5, minimumSignificantDigits: #3, diff --git a/test/intl/Intl__RelativeTimeFormatTest.mjs b/test/intl/Intl__RelativeTimeFormatTest.mjs index 062d89be..2afbbac3 100644 --- a/test/intl/Intl__RelativeTimeFormatTest.mjs +++ b/test/intl/Intl__RelativeTimeFormatTest.mjs @@ -8,7 +8,7 @@ console.log("Intl.RelativeTimeFormat"); Intl.RelativeTimeFormat.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.RelativeTimeFormat.supportedLocalesOf([ "en-US", @@ -17,21 +17,14 @@ Intl.RelativeTimeFormat.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.RelativeTimeFormat(); - -new Intl.RelativeTimeFormat("en-US"); +new Intl.RelativeTimeFormat(undefined, undefined); new Intl.RelativeTimeFormat([ "en-US", "en-GB" - ]); - -new Intl.RelativeTimeFormat(undefined, { - numeric: "always", - style: "narrow" - }); + ], undefined); -var _formatter = new Intl.RelativeTimeFormat("en-US", { +var _formatter = new Intl.RelativeTimeFormat(undefined, { numeric: "always", style: "narrow" }); diff --git a/test/intl/Intl__RelativeTimeFormatTest.res b/test/intl/Intl__RelativeTimeFormatTest.res index e8833d7c..6f53ad7e 100644 --- a/test/intl/Intl__RelativeTimeFormatTest.res +++ b/test/intl/Intl__RelativeTimeFormatTest.res @@ -4,28 +4,22 @@ Console.log("---") Console.log("Intl.RelativeTimeFormat") Intl.RelativeTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.RelativeTimeFormat.supportedLocalesOfWithOptions( +Intl.RelativeTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], - {localeMatcher: #lookup}, + ~options={localeMatcher: #lookup}, )->ignore let _formatter = Intl.RelativeTimeFormat.make() -let _formatter = Intl.RelativeTimeFormat.makeWithLocale("en-US") -let _formatter = Intl.RelativeTimeFormat.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.RelativeTimeFormat.makeWithOptions({ - numeric: #always, - style: #narrow, -}) -let _formatter = Intl.RelativeTimeFormat.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.RelativeTimeFormat.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.RelativeTimeFormat.make( + ~options={ numeric: #always, style: #narrow, }, ) -let formatter = Intl.RelativeTimeFormat.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.RelativeTimeFormat.make( + ~locales=["en-US"], + ~options={ numeric: #always, style: #narrow, }, diff --git a/test/intl/Intl__SegmenterTest.mjs b/test/intl/Intl__SegmenterTest.mjs index 757c7c4d..c1d6ecf0 100644 --- a/test/intl/Intl__SegmenterTest.mjs +++ b/test/intl/Intl__SegmenterTest.mjs @@ -8,7 +8,7 @@ console.log("Intl.Segmenter"); Intl.Segmenter.supportedLocalesOf([ "en-US", "en-GB" - ]); + ], undefined); Intl.Segmenter.supportedLocalesOf([ "en-US", @@ -17,20 +17,14 @@ Intl.Segmenter.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.Segmenter(); - -new Intl.Segmenter("en-US"); +new Intl.Segmenter(undefined, undefined); new Intl.Segmenter([ "en-US", "en-GB" - ]); - -new Intl.Segmenter(undefined, { - granularity: "word" - }); + ], undefined); -var _formatter = new Intl.Segmenter("en-US", { +var _formatter = new Intl.Segmenter(undefined, { granularity: "word" }); diff --git a/test/intl/Intl__SegmenterTest.res b/test/intl/Intl__SegmenterTest.res index aaca4153..ed322939 100644 --- a/test/intl/Intl__SegmenterTest.res +++ b/test/intl/Intl__SegmenterTest.res @@ -4,23 +4,18 @@ Console.log("---") Console.log("Intl.Segmenter") Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"])->ignore -Intl.Segmenter.supportedLocalesOfWithOptions(["en-US", "en-GB"], {localeMatcher: #lookup})->ignore +Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore let _formatter = Intl.Segmenter.make() -let _formatter = Intl.Segmenter.makeWithLocale("en-US") -let _formatter = Intl.Segmenter.makeWithLocales(["en-US", "en-GB"]) -let _formatter = Intl.Segmenter.makeWithOptions({ - granularity: #word, -}) -let _formatter = Intl.Segmenter.makeWithLocaleAndOptions( - "en-US", - { +let _formatter = Intl.Segmenter.make(~locales=["en-US", "en-GB"]) +let _formatter = Intl.Segmenter.make( + ~options={ granularity: #word, }, ) -let formatter = Intl.Segmenter.makeWithLocalesAndOptions( - ["en-US"], - { +let formatter = Intl.Segmenter.make( + ~locales=["en-US"], + ~options={ granularity: #word, }, )