@formatjs/intl-enumerator 1.1.9 → 1.2.0
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/lib/src/get-supported-calendars.d.ts +1 -1
- package/lib/src/get-supported-calendars.d.ts.map +1 -1
- package/lib/src/get-supported-calendars.js +7 -4
- package/lib/src/get-supported-collations.d.ts +1 -1
- package/lib/src/get-supported-collations.d.ts.map +1 -1
- package/lib/src/get-supported-collations.js +6 -4
- package/lib/src/get-supported-currencies.d.ts +1 -1
- package/lib/src/get-supported-currencies.d.ts.map +1 -1
- package/lib/src/get-supported-currencies.js +6 -5
- package/lib/src/get-supported-numbering-systems.d.ts +1 -1
- package/lib/src/get-supported-numbering-systems.d.ts.map +1 -1
- package/lib/src/get-supported-numbering-systems.js +7 -4
- package/lib/src/get-supported-timezones.d.ts +1 -1
- package/lib/src/get-supported-timezones.d.ts.map +1 -1
- package/lib/src/get-supported-timezones.js +5 -4
- package/lib/src/get-supported-units.d.ts +1 -1
- package/lib/src/get-supported-units.d.ts.map +1 -1
- package/lib/src/get-supported-units.js +5 -4
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +7 -7
- package/package.json +3 -3
- package/src/get-supported-calendars.d.ts +1 -1
- package/src/get-supported-calendars.d.ts.map +1 -1
- package/src/get-supported-calendars.js +7 -4
- package/src/get-supported-collations.d.ts +1 -1
- package/src/get-supported-collations.d.ts.map +1 -1
- package/src/get-supported-collations.js +6 -4
- package/src/get-supported-currencies.d.ts +1 -1
- package/src/get-supported-currencies.d.ts.map +1 -1
- package/src/get-supported-currencies.js +6 -5
- package/src/get-supported-numbering-systems.d.ts +1 -1
- package/src/get-supported-numbering-systems.d.ts.map +1 -1
- package/src/get-supported-numbering-systems.js +7 -4
- package/src/get-supported-timezones.d.ts +1 -1
- package/src/get-supported-timezones.d.ts.map +1 -1
- package/src/get-supported-timezones.js +5 -4
- package/src/get-supported-units.d.ts +1 -1
- package/src/get-supported-units.d.ts.map +1 -1
- package/src/get-supported-units.js +5 -4
- package/src/index.d.ts +1 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-calendars.d.ts","sourceRoot":"","sources":["../../src/get-supported-calendars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAcnD,wBAAgB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-supported-calendars.d.ts","sourceRoot":"","sources":["../../src/get-supported-calendars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAcnD,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAIvE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { calendars } from './calendars.generated';
|
|
2
|
-
function isSupportedCalendar(item) {
|
|
2
|
+
function isSupportedCalendar(item, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
var dateTimeFormat = new Intl.DateTimeFormat(
|
|
5
|
+
var dateTimeFormat = new Intl.DateTimeFormat("".concat(locale, "-u-ca-").concat(item));
|
|
5
6
|
var options = dateTimeFormat.resolvedOptions().calendar;
|
|
6
7
|
if (item !== 'gregory' || options !== 'gregory')
|
|
7
8
|
return true;
|
|
@@ -9,6 +10,8 @@ function isSupportedCalendar(item) {
|
|
|
9
10
|
catch (_err) { }
|
|
10
11
|
return false;
|
|
11
12
|
}
|
|
12
|
-
export function getSupportedCalendars() {
|
|
13
|
-
return calendars.filter(
|
|
13
|
+
export function getSupportedCalendars(localePrefix) {
|
|
14
|
+
return calendars.filter(function (calendar) {
|
|
15
|
+
return isSupportedCalendar(calendar, localePrefix);
|
|
16
|
+
});
|
|
14
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-collations.d.ts","sourceRoot":"","sources":["../../src/get-supported-collations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"get-supported-collations.d.ts","sourceRoot":"","sources":["../../src/get-supported-collations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAcrD,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAEnE"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { collations } from './collations.generated';
|
|
2
|
-
function isSupported(collation) {
|
|
2
|
+
function isSupported(collation, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
return (Intl.Collator(
|
|
5
|
+
return (Intl.Collator("".concat(locale, "-u-co-").concat(collation)).resolvedOptions()
|
|
6
|
+
.collation === collation);
|
|
5
7
|
}
|
|
6
8
|
catch (_err) { }
|
|
7
9
|
return false;
|
|
8
10
|
}
|
|
9
|
-
export function getSupportedCollations() {
|
|
10
|
-
return collations.filter(isSupported);
|
|
11
|
+
export function getSupportedCollations(locale) {
|
|
12
|
+
return collations.filter(function (collation) { return isSupported(collation, locale); });
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-currencies.d.ts","sourceRoot":"","sources":["../../src/get-supported-currencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"get-supported-currencies.d.ts","sourceRoot":"","sources":["../../src/get-supported-currencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AA2BpD,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAuBlE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { currencies } from './currencies.generated';
|
|
2
|
-
function isSupportedCurrency(currency) {
|
|
2
|
+
function isSupportedCurrency(currency, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
var numberFormat = new Intl.NumberFormat(
|
|
5
|
+
var numberFormat = new Intl.NumberFormat(locale, {
|
|
5
6
|
style: 'currency',
|
|
6
7
|
currencyDisplay: 'name',
|
|
7
8
|
currency: currency,
|
|
@@ -15,13 +16,13 @@ function isSupportedCurrency(currency) {
|
|
|
15
16
|
catch (_err) { }
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
|
-
export function getSupportedCurrencies() {
|
|
19
|
+
export function getSupportedCurrencies(locale) {
|
|
19
20
|
var ATOZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
20
21
|
var supportedCurrencies = [];
|
|
21
22
|
for (var _i = 0, currencies_1 = currencies; _i < currencies_1.length; _i++) {
|
|
22
23
|
var currency = currencies_1[_i];
|
|
23
24
|
if (currency.length === 3) {
|
|
24
|
-
if (isSupportedCurrency(currency)) {
|
|
25
|
+
if (isSupportedCurrency(currency, locale)) {
|
|
25
26
|
supportedCurrencies.push(currency);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -30,7 +31,7 @@ export function getSupportedCurrencies() {
|
|
|
30
31
|
var end = ATOZ.indexOf(currency[4]);
|
|
31
32
|
for (var i = start; i <= end; i++) {
|
|
32
33
|
var currentCurrency = (currency.substring(0, 2) + ATOZ[i]);
|
|
33
|
-
if (isSupportedCurrency(currentCurrency)) {
|
|
34
|
+
if (isSupportedCurrency(currentCurrency, locale)) {
|
|
34
35
|
supportedCurrencies.push(currentCurrency);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getSupportedNumberingSystems(): string[];
|
|
1
|
+
export declare function getSupportedNumberingSystems(locale?: string): string[];
|
|
2
2
|
//# sourceMappingURL=get-supported-numbering-systems.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-numbering-systems.d.ts","sourceRoot":"","sources":["../../src/get-supported-numbering-systems.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-supported-numbering-systems.d.ts","sourceRoot":"","sources":["../../src/get-supported-numbering-systems.ts"],"names":[],"mappings":"AAqBA,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAItE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { numberingSystemNames } from './numbering-systems.generated';
|
|
2
|
-
function isSupportedNumberingSystem(system) {
|
|
2
|
+
function isSupportedNumberingSystem(system, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
var numberFormat = new Intl.NumberFormat(
|
|
5
|
+
var numberFormat = new Intl.NumberFormat("".concat(locale, "-u-nu-").concat(system));
|
|
5
6
|
var options = numberFormat.resolvedOptions().numberingSystem;
|
|
6
7
|
if ((options === system && system === 'latn') ||
|
|
7
8
|
numberFormat.format(123) !== '123') {
|
|
@@ -11,6 +12,8 @@ function isSupportedNumberingSystem(system) {
|
|
|
11
12
|
catch (_err) { }
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
|
-
export function getSupportedNumberingSystems() {
|
|
15
|
-
return numberingSystemNames.filter(
|
|
15
|
+
export function getSupportedNumberingSystems(locale) {
|
|
16
|
+
return numberingSystemNames.filter(function (numberingSystemName) {
|
|
17
|
+
return isSupportedNumberingSystem(numberingSystemName, locale);
|
|
18
|
+
});
|
|
16
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-timezones.d.ts","sourceRoot":"","sources":["../../src/get-supported-timezones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAYnD,wBAAgB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-supported-timezones.d.ts","sourceRoot":"","sources":["../../src/get-supported-timezones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAYnD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEjE"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { timezones } from './timezones.generated';
|
|
2
|
-
function isSupported(timeZone) {
|
|
2
|
+
function isSupported(timeZone, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
var formatter = new Intl.DateTimeFormat(
|
|
5
|
+
var formatter = new Intl.DateTimeFormat(locale, { timeZone: timeZone });
|
|
5
6
|
return formatter.resolvedOptions().timeZone === timeZone;
|
|
6
7
|
}
|
|
7
8
|
catch (_err) { }
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
|
-
export function getSupportedTimeZones() {
|
|
11
|
-
return timezones.filter(isSupported);
|
|
11
|
+
export function getSupportedTimeZones(locale) {
|
|
12
|
+
return timezones.filter(function (timezone) { return isSupported(timezone, locale); });
|
|
12
13
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getSupportedUnits(): ("degree" | "acre" | "hectare" | "percent" | "bit" | "byte" | "gigabit" | "gigabyte" | "kilobit" | "kilobyte" | "megabit" | "megabyte" | "petabyte" | "terabit" | "terabyte" | "day" | "hour" | "millisecond" | "minute" | "month" | "second" | "week" | "year" | "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile-scandinavian" | "mile" | "millimeter" | "yard" | "gram" | "kilogram" | "ounce" | "pound" | "stone" | "celsius" | "fahrenheit" | "fluid-ounce" | "gallon" | "liter" | "milliliter")[];
|
|
1
|
+
export declare function getSupportedUnits(locale?: string): ("degree" | "acre" | "hectare" | "percent" | "bit" | "byte" | "gigabit" | "gigabyte" | "kilobit" | "kilobyte" | "megabit" | "megabyte" | "petabyte" | "terabit" | "terabyte" | "day" | "hour" | "millisecond" | "minute" | "month" | "second" | "week" | "year" | "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile-scandinavian" | "mile" | "millimeter" | "yard" | "gram" | "kilogram" | "ounce" | "pound" | "stone" | "celsius" | "fahrenheit" | "fluid-ounce" | "gallon" | "liter" | "milliliter")[];
|
|
2
2
|
//# sourceMappingURL=get-supported-units.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-units.d.ts","sourceRoot":"","sources":["../../src/get-supported-units.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"get-supported-units.d.ts","sourceRoot":"","sources":["../../src/get-supported-units.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,yfAEhD"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { units } from './units.generated';
|
|
2
|
-
function isSupported(unit) {
|
|
2
|
+
function isSupported(unit, locale) {
|
|
3
|
+
if (locale === void 0) { locale = 'en'; }
|
|
3
4
|
try {
|
|
4
|
-
var formatter = new Intl.NumberFormat(
|
|
5
|
+
var formatter = new Intl.NumberFormat(locale, { style: 'unit', unit: unit });
|
|
5
6
|
return formatter.resolvedOptions().unit === unit;
|
|
6
7
|
}
|
|
7
8
|
catch (_err) { }
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
|
-
export function getSupportedUnits() {
|
|
11
|
-
return units.filter(isSupported);
|
|
11
|
+
export function getSupportedUnits(locale) {
|
|
12
|
+
return units.filter(function (unit) { return isSupported(unit, locale); });
|
|
12
13
|
}
|
package/lib/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type SupportedValuesOf = 'calendar' | 'collation' | 'currency' | 'numberingSystem' | 'timeZone' | 'unit';
|
|
2
|
-
export declare function supportedValuesOf(key: SupportedValuesOf): string[];
|
|
2
|
+
export declare function supportedValuesOf(key: SupportedValuesOf, locale?: string): string[];
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,WAAW,GACX,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,MAAM,CAAA;AAEV,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,WAAW,GACX,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,MAAM,CAAA;AAEV,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,EAAE,CAiBV"}
|
package/lib/src/index.js
CHANGED
|
@@ -4,20 +4,20 @@ import { getSupportedCurrencies } from './get-supported-currencies';
|
|
|
4
4
|
import { getSupportedNumberingSystems } from './get-supported-numbering-systems';
|
|
5
5
|
import { getSupportedTimeZones } from './get-supported-timezones';
|
|
6
6
|
import { getSupportedUnits } from './get-supported-units';
|
|
7
|
-
export function supportedValuesOf(key) {
|
|
7
|
+
export function supportedValuesOf(key, locale) {
|
|
8
8
|
switch (key) {
|
|
9
9
|
case 'calendar':
|
|
10
|
-
return getSupportedCalendars();
|
|
10
|
+
return getSupportedCalendars(locale);
|
|
11
11
|
case 'collation':
|
|
12
|
-
return getSupportedCollations();
|
|
12
|
+
return getSupportedCollations(locale);
|
|
13
13
|
case 'currency':
|
|
14
|
-
return getSupportedCurrencies();
|
|
14
|
+
return getSupportedCurrencies(locale);
|
|
15
15
|
case 'numberingSystem':
|
|
16
|
-
return getSupportedNumberingSystems();
|
|
16
|
+
return getSupportedNumberingSystems(locale);
|
|
17
17
|
case 'timeZone':
|
|
18
|
-
return getSupportedTimeZones();
|
|
18
|
+
return getSupportedTimeZones(locale);
|
|
19
19
|
case 'unit':
|
|
20
|
-
return getSupportedUnits();
|
|
20
|
+
return getSupportedUnits(locale);
|
|
21
21
|
default:
|
|
22
22
|
throw RangeError('Invalid key: ' + key);
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-enumerator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Intl.Enumerator polyfill",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"url": "https://github.com/formatjs/formatjs/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"tslib": "2.4.0"
|
|
27
|
+
"tslib": "^2.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@formatjs/ecma402-abstract": "1.14.
|
|
30
|
+
"@formatjs/ecma402-abstract": "1.14.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-calendars.d.ts","sourceRoot":"","sources":["get-supported-calendars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAcnD,wBAAgB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-supported-calendars.d.ts","sourceRoot":"","sources":["get-supported-calendars.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAcnD,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAIvE"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedCalendars = void 0;
|
|
4
4
|
var calendars_generated_1 = require("./calendars.generated");
|
|
5
|
-
function isSupportedCalendar(item) {
|
|
5
|
+
function isSupportedCalendar(item, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
var dateTimeFormat = new Intl.DateTimeFormat(
|
|
8
|
+
var dateTimeFormat = new Intl.DateTimeFormat("".concat(locale, "-u-ca-").concat(item));
|
|
8
9
|
var options = dateTimeFormat.resolvedOptions().calendar;
|
|
9
10
|
if (item !== 'gregory' || options !== 'gregory')
|
|
10
11
|
return true;
|
|
@@ -12,7 +13,9 @@ function isSupportedCalendar(item) {
|
|
|
12
13
|
catch (_err) { }
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
|
-
function getSupportedCalendars() {
|
|
16
|
-
return calendars_generated_1.calendars.filter(
|
|
16
|
+
function getSupportedCalendars(localePrefix) {
|
|
17
|
+
return calendars_generated_1.calendars.filter(function (calendar) {
|
|
18
|
+
return isSupportedCalendar(calendar, localePrefix);
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
exports.getSupportedCalendars = getSupportedCalendars;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-collations.d.ts","sourceRoot":"","sources":["get-supported-collations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"get-supported-collations.d.ts","sourceRoot":"","sources":["get-supported-collations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAcrD,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAEnE"}
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedCollations = void 0;
|
|
4
4
|
var collations_generated_1 = require("./collations.generated");
|
|
5
|
-
function isSupported(collation) {
|
|
5
|
+
function isSupported(collation, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
return (Intl.Collator(
|
|
8
|
+
return (Intl.Collator("".concat(locale, "-u-co-").concat(collation)).resolvedOptions()
|
|
9
|
+
.collation === collation);
|
|
8
10
|
}
|
|
9
11
|
catch (_err) { }
|
|
10
12
|
return false;
|
|
11
13
|
}
|
|
12
|
-
function getSupportedCollations() {
|
|
13
|
-
return collations_generated_1.collations.filter(isSupported);
|
|
14
|
+
function getSupportedCollations(locale) {
|
|
15
|
+
return collations_generated_1.collations.filter(function (collation) { return isSupported(collation, locale); });
|
|
14
16
|
}
|
|
15
17
|
exports.getSupportedCollations = getSupportedCollations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-currencies.d.ts","sourceRoot":"","sources":["get-supported-currencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"get-supported-currencies.d.ts","sourceRoot":"","sources":["get-supported-currencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AA2BpD,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAuBlE"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedCurrencies = void 0;
|
|
4
4
|
var currencies_generated_1 = require("./currencies.generated");
|
|
5
|
-
function isSupportedCurrency(currency) {
|
|
5
|
+
function isSupportedCurrency(currency, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
var numberFormat = new Intl.NumberFormat(
|
|
8
|
+
var numberFormat = new Intl.NumberFormat(locale, {
|
|
8
9
|
style: 'currency',
|
|
9
10
|
currencyDisplay: 'name',
|
|
10
11
|
currency: currency,
|
|
@@ -18,13 +19,13 @@ function isSupportedCurrency(currency) {
|
|
|
18
19
|
catch (_err) { }
|
|
19
20
|
return false;
|
|
20
21
|
}
|
|
21
|
-
function getSupportedCurrencies() {
|
|
22
|
+
function getSupportedCurrencies(locale) {
|
|
22
23
|
var ATOZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
23
24
|
var supportedCurrencies = [];
|
|
24
25
|
for (var _i = 0, currencies_1 = currencies_generated_1.currencies; _i < currencies_1.length; _i++) {
|
|
25
26
|
var currency = currencies_1[_i];
|
|
26
27
|
if (currency.length === 3) {
|
|
27
|
-
if (isSupportedCurrency(currency)) {
|
|
28
|
+
if (isSupportedCurrency(currency, locale)) {
|
|
28
29
|
supportedCurrencies.push(currency);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -33,7 +34,7 @@ function getSupportedCurrencies() {
|
|
|
33
34
|
var end = ATOZ.indexOf(currency[4]);
|
|
34
35
|
for (var i = start; i <= end; i++) {
|
|
35
36
|
var currentCurrency = (currency.substring(0, 2) + ATOZ[i]);
|
|
36
|
-
if (isSupportedCurrency(currentCurrency)) {
|
|
37
|
+
if (isSupportedCurrency(currentCurrency, locale)) {
|
|
37
38
|
supportedCurrencies.push(currentCurrency);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getSupportedNumberingSystems(): string[];
|
|
1
|
+
export declare function getSupportedNumberingSystems(locale?: string): string[];
|
|
2
2
|
//# sourceMappingURL=get-supported-numbering-systems.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-numbering-systems.d.ts","sourceRoot":"","sources":["get-supported-numbering-systems.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-supported-numbering-systems.d.ts","sourceRoot":"","sources":["get-supported-numbering-systems.ts"],"names":[],"mappings":"AAqBA,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAItE"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedNumberingSystems = void 0;
|
|
4
4
|
var numbering_systems_generated_1 = require("./numbering-systems.generated");
|
|
5
|
-
function isSupportedNumberingSystem(system) {
|
|
5
|
+
function isSupportedNumberingSystem(system, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
var numberFormat = new Intl.NumberFormat(
|
|
8
|
+
var numberFormat = new Intl.NumberFormat("".concat(locale, "-u-nu-").concat(system));
|
|
8
9
|
var options = numberFormat.resolvedOptions().numberingSystem;
|
|
9
10
|
if ((options === system && system === 'latn') ||
|
|
10
11
|
numberFormat.format(123) !== '123') {
|
|
@@ -14,7 +15,9 @@ function isSupportedNumberingSystem(system) {
|
|
|
14
15
|
catch (_err) { }
|
|
15
16
|
return false;
|
|
16
17
|
}
|
|
17
|
-
function getSupportedNumberingSystems() {
|
|
18
|
-
return numbering_systems_generated_1.numberingSystemNames.filter(
|
|
18
|
+
function getSupportedNumberingSystems(locale) {
|
|
19
|
+
return numbering_systems_generated_1.numberingSystemNames.filter(function (numberingSystemName) {
|
|
20
|
+
return isSupportedNumberingSystem(numberingSystemName, locale);
|
|
21
|
+
});
|
|
19
22
|
}
|
|
20
23
|
exports.getSupportedNumberingSystems = getSupportedNumberingSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-timezones.d.ts","sourceRoot":"","sources":["get-supported-timezones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAYnD,wBAAgB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-supported-timezones.d.ts","sourceRoot":"","sources":["get-supported-timezones.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAYnD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEjE"}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedTimeZones = void 0;
|
|
4
4
|
var timezones_generated_1 = require("./timezones.generated");
|
|
5
|
-
function isSupported(timeZone) {
|
|
5
|
+
function isSupported(timeZone, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
var formatter = new Intl.DateTimeFormat(
|
|
8
|
+
var formatter = new Intl.DateTimeFormat(locale, { timeZone: timeZone });
|
|
8
9
|
return formatter.resolvedOptions().timeZone === timeZone;
|
|
9
10
|
}
|
|
10
11
|
catch (_err) { }
|
|
11
12
|
return false;
|
|
12
13
|
}
|
|
13
|
-
function getSupportedTimeZones() {
|
|
14
|
-
return timezones_generated_1.timezones.filter(isSupported);
|
|
14
|
+
function getSupportedTimeZones(locale) {
|
|
15
|
+
return timezones_generated_1.timezones.filter(function (timezone) { return isSupported(timezone, locale); });
|
|
15
16
|
}
|
|
16
17
|
exports.getSupportedTimeZones = getSupportedTimeZones;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getSupportedUnits(): ("degree" | "acre" | "hectare" | "percent" | "bit" | "byte" | "gigabit" | "gigabyte" | "kilobit" | "kilobyte" | "megabit" | "megabyte" | "petabyte" | "terabit" | "terabyte" | "day" | "hour" | "millisecond" | "minute" | "month" | "second" | "week" | "year" | "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile-scandinavian" | "mile" | "millimeter" | "yard" | "gram" | "kilogram" | "ounce" | "pound" | "stone" | "celsius" | "fahrenheit" | "fluid-ounce" | "gallon" | "liter" | "milliliter")[];
|
|
1
|
+
export declare function getSupportedUnits(locale?: string): ("degree" | "acre" | "hectare" | "percent" | "bit" | "byte" | "gigabit" | "gigabyte" | "kilobit" | "kilobyte" | "megabit" | "megabyte" | "petabyte" | "terabit" | "terabyte" | "day" | "hour" | "millisecond" | "minute" | "month" | "second" | "week" | "year" | "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile-scandinavian" | "mile" | "millimeter" | "yard" | "gram" | "kilogram" | "ounce" | "pound" | "stone" | "celsius" | "fahrenheit" | "fluid-ounce" | "gallon" | "liter" | "milliliter")[];
|
|
2
2
|
//# sourceMappingURL=get-supported-units.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-supported-units.d.ts","sourceRoot":"","sources":["get-supported-units.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"get-supported-units.d.ts","sourceRoot":"","sources":["get-supported-units.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,yfAEhD"}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSupportedUnits = void 0;
|
|
4
4
|
var units_generated_1 = require("./units.generated");
|
|
5
|
-
function isSupported(unit) {
|
|
5
|
+
function isSupported(unit, locale) {
|
|
6
|
+
if (locale === void 0) { locale = 'en'; }
|
|
6
7
|
try {
|
|
7
|
-
var formatter = new Intl.NumberFormat(
|
|
8
|
+
var formatter = new Intl.NumberFormat(locale, { style: 'unit', unit: unit });
|
|
8
9
|
return formatter.resolvedOptions().unit === unit;
|
|
9
10
|
}
|
|
10
11
|
catch (_err) { }
|
|
11
12
|
return false;
|
|
12
13
|
}
|
|
13
|
-
function getSupportedUnits() {
|
|
14
|
-
return units_generated_1.units.filter(isSupported);
|
|
14
|
+
function getSupportedUnits(locale) {
|
|
15
|
+
return units_generated_1.units.filter(function (unit) { return isSupported(unit, locale); });
|
|
15
16
|
}
|
|
16
17
|
exports.getSupportedUnits = getSupportedUnits;
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type SupportedValuesOf = 'calendar' | 'collation' | 'currency' | 'numberingSystem' | 'timeZone' | 'unit';
|
|
2
|
-
export declare function supportedValuesOf(key: SupportedValuesOf): string[];
|
|
2
|
+
export declare function supportedValuesOf(key: SupportedValuesOf, locale?: string): string[];
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,WAAW,GACX,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,MAAM,CAAA;AAEV,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,WAAW,GACX,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,MAAM,CAAA;AAEV,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,EAAE,CAiBV"}
|
package/src/index.js
CHANGED
|
@@ -7,20 +7,20 @@ var get_supported_currencies_1 = require("./get-supported-currencies");
|
|
|
7
7
|
var get_supported_numbering_systems_1 = require("./get-supported-numbering-systems");
|
|
8
8
|
var get_supported_timezones_1 = require("./get-supported-timezones");
|
|
9
9
|
var get_supported_units_1 = require("./get-supported-units");
|
|
10
|
-
function supportedValuesOf(key) {
|
|
10
|
+
function supportedValuesOf(key, locale) {
|
|
11
11
|
switch (key) {
|
|
12
12
|
case 'calendar':
|
|
13
|
-
return (0, get_supported_calendars_1.getSupportedCalendars)();
|
|
13
|
+
return (0, get_supported_calendars_1.getSupportedCalendars)(locale);
|
|
14
14
|
case 'collation':
|
|
15
|
-
return (0, get_supported_collations_1.getSupportedCollations)();
|
|
15
|
+
return (0, get_supported_collations_1.getSupportedCollations)(locale);
|
|
16
16
|
case 'currency':
|
|
17
|
-
return (0, get_supported_currencies_1.getSupportedCurrencies)();
|
|
17
|
+
return (0, get_supported_currencies_1.getSupportedCurrencies)(locale);
|
|
18
18
|
case 'numberingSystem':
|
|
19
|
-
return (0, get_supported_numbering_systems_1.getSupportedNumberingSystems)();
|
|
19
|
+
return (0, get_supported_numbering_systems_1.getSupportedNumberingSystems)(locale);
|
|
20
20
|
case 'timeZone':
|
|
21
|
-
return (0, get_supported_timezones_1.getSupportedTimeZones)();
|
|
21
|
+
return (0, get_supported_timezones_1.getSupportedTimeZones)(locale);
|
|
22
22
|
case 'unit':
|
|
23
|
-
return (0, get_supported_units_1.getSupportedUnits)();
|
|
23
|
+
return (0, get_supported_units_1.getSupportedUnits)(locale);
|
|
24
24
|
default:
|
|
25
25
|
throw RangeError('Invalid key: ' + key);
|
|
26
26
|
}
|