@formatjs/intl-displaynames 6.8.13 → 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/abstract/CanonicalCodeForDisplayNames.js +7 -10
- package/abstract/IsValidDateTimeFieldCode.js +1 -4
- package/index.js +30 -33
- package/package.json +13 -6
- package/polyfill-force.js +2 -4
- package/polyfill.iife.js +35 -36
- package/polyfill.js +4 -6
- package/should-polyfill.js +6 -10
- package/supported-locales.generated.js +1 -4
- package/lib/abstract/CanonicalCodeForDisplayNames.d.ts +0 -1
- package/lib/abstract/CanonicalCodeForDisplayNames.js +0 -48
- package/lib/abstract/IsValidDateTimeFieldCode.d.ts +0 -1
- package/lib/abstract/IsValidDateTimeFieldCode.js +0 -17
- package/lib/index.d.ts +0 -27
- package/lib/index.js +0 -210
- package/lib/polyfill-force.d.ts +0 -1
- package/lib/polyfill-force.js +0 -7
- package/lib/polyfill.d.ts +0 -1
- package/lib/polyfill.js +0 -10
- package/lib/should-polyfill.d.ts +0 -2
- package/lib/should-polyfill.js +0 -48
- package/lib/supported-locales.generated.d.ts +0 -1
- package/lib/supported-locales.generated.js +0 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CanonicalCodeForDisplayNames = CanonicalCodeForDisplayNames;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
var IsValidDateTimeFieldCode_1 = require("./IsValidDateTimeFieldCode");
|
|
1
|
+
import { CanonicalizeLocaleList, invariant, IsWellFormedCurrencyCode, } from '@formatjs/ecma402-abstract';
|
|
2
|
+
import { IsValidDateTimeFieldCode } from './IsValidDateTimeFieldCode';
|
|
6
3
|
var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
|
|
7
4
|
var ALPHA_4 = /^[a-z]{4}$/i;
|
|
8
5
|
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
|
|
@@ -15,9 +12,9 @@ function isUnicodeScriptSubtag(script) {
|
|
|
15
12
|
function isUnicodeLocaleIdentifierType(code) {
|
|
16
13
|
return UNICODE_TYPE_REGEX.test(code);
|
|
17
14
|
}
|
|
18
|
-
function CanonicalCodeForDisplayNames(type, code) {
|
|
15
|
+
export function CanonicalCodeForDisplayNames(type, code) {
|
|
19
16
|
if (type === 'language') {
|
|
20
|
-
return
|
|
17
|
+
return CanonicalizeLocaleList([code])[0];
|
|
21
18
|
}
|
|
22
19
|
if (type === 'region') {
|
|
23
20
|
if (!isUnicodeRegionSubtag(code)) {
|
|
@@ -38,13 +35,13 @@ function CanonicalCodeForDisplayNames(type, code) {
|
|
|
38
35
|
return code.toLowerCase();
|
|
39
36
|
}
|
|
40
37
|
if (type === 'dateTimeField') {
|
|
41
|
-
if (!
|
|
38
|
+
if (!IsValidDateTimeFieldCode(code)) {
|
|
42
39
|
throw RangeError('invalid dateTimeField');
|
|
43
40
|
}
|
|
44
41
|
return code;
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
if (!
|
|
43
|
+
invariant(type === 'currency', 'invalid type');
|
|
44
|
+
if (!IsWellFormedCurrencyCode(code)) {
|
|
48
45
|
throw RangeError('invalid currency');
|
|
49
46
|
}
|
|
50
47
|
return code.toUpperCase();
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsValidDateTimeFieldCode = IsValidDateTimeFieldCode;
|
|
4
1
|
var CODES_FOR_DATE_TIME_FIELD = [
|
|
5
2
|
'era',
|
|
6
3
|
'year',
|
|
@@ -15,6 +12,6 @@ var CODES_FOR_DATE_TIME_FIELD = [
|
|
|
15
12
|
'second',
|
|
16
13
|
'timeZoneName',
|
|
17
14
|
];
|
|
18
|
-
function IsValidDateTimeFieldCode(field) {
|
|
15
|
+
export function IsValidDateTimeFieldCode(field) {
|
|
19
16
|
return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
|
|
20
17
|
}
|
package/index.js
CHANGED
|
@@ -1,60 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var CanonicalCodeForDisplayNames_1 = require("./abstract/CanonicalCodeForDisplayNames");
|
|
7
|
-
var IsValidDateTimeFieldCode_1 = require("./abstract/IsValidDateTimeFieldCode");
|
|
8
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { CanonicalizeLocaleList, GetOption, GetOptionsObject, IsWellFormedCurrencyCode, SupportedLocales, ToString, getInternalSlot, getMultiInternalSlots, invariant, setInternalSlot, } from '@formatjs/ecma402-abstract';
|
|
3
|
+
import { CanonicalCodeForDisplayNames } from './abstract/CanonicalCodeForDisplayNames.js';
|
|
4
|
+
import { IsValidDateTimeFieldCode } from './abstract/IsValidDateTimeFieldCode.js';
|
|
5
|
+
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
9
6
|
var DisplayNames = /** @class */ (function () {
|
|
10
7
|
function DisplayNames(locales, options) {
|
|
11
8
|
var _newTarget = this.constructor;
|
|
12
9
|
if (_newTarget === undefined) {
|
|
13
10
|
throw TypeError("Constructor Intl.DisplayNames requires 'new'");
|
|
14
11
|
}
|
|
15
|
-
var requestedLocales =
|
|
16
|
-
options =
|
|
12
|
+
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
13
|
+
options = GetOptionsObject(options);
|
|
17
14
|
var opt = Object.create(null);
|
|
18
15
|
var localeData = DisplayNames.localeData;
|
|
19
|
-
var matcher =
|
|
16
|
+
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
20
17
|
opt.localeMatcher = matcher;
|
|
21
|
-
var r =
|
|
18
|
+
var r = ResolveLocale(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], // there is no relevantExtensionKeys
|
|
22
19
|
DisplayNames.localeData, DisplayNames.getDefaultLocale);
|
|
23
|
-
var style =
|
|
20
|
+
var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
|
|
24
21
|
setSlot(this, 'style', style);
|
|
25
|
-
var type =
|
|
22
|
+
var type = GetOption(options, 'type', 'string', ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'], undefined);
|
|
26
23
|
if (type === undefined) {
|
|
27
24
|
throw TypeError("Intl.DisplayNames constructor requires \"type\" option");
|
|
28
25
|
}
|
|
29
26
|
setSlot(this, 'type', type);
|
|
30
|
-
var fallback =
|
|
27
|
+
var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
|
|
31
28
|
setSlot(this, 'fallback', fallback);
|
|
32
29
|
setSlot(this, 'locale', r.locale);
|
|
33
30
|
var dataLocale = r.dataLocale;
|
|
34
31
|
var dataLocaleData = localeData[dataLocale];
|
|
35
|
-
|
|
32
|
+
invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
|
|
36
33
|
setSlot(this, 'localeData', dataLocaleData);
|
|
37
|
-
|
|
34
|
+
invariant(dataLocaleData !== undefined, "locale data for ".concat(r.locale, " does not exist."));
|
|
38
35
|
var types = dataLocaleData.types;
|
|
39
|
-
|
|
36
|
+
invariant(typeof types === 'object' && types != null, 'invalid types data');
|
|
40
37
|
var typeFields = types[type];
|
|
41
|
-
|
|
42
|
-
var languageDisplay =
|
|
38
|
+
invariant(typeof typeFields === 'object' && typeFields != null, 'invalid typeFields data');
|
|
39
|
+
var languageDisplay = GetOption(options, 'languageDisplay', 'string', ['dialect', 'standard'], 'dialect');
|
|
43
40
|
if (type === 'language') {
|
|
44
41
|
setSlot(this, 'languageDisplay', languageDisplay);
|
|
45
42
|
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
|
|
46
43
|
var typeFields_1 = types[type][languageDisplay];
|
|
47
|
-
|
|
44
|
+
invariant(typeof typeFields_1 === 'object' && typeFields_1 != null, 'invalid language typeFields data');
|
|
48
45
|
}
|
|
49
46
|
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
|
|
50
47
|
var styleFields = type === 'language'
|
|
51
48
|
? types[type][languageDisplay][style]
|
|
52
49
|
: types[type][style];
|
|
53
|
-
|
|
50
|
+
invariant(typeof styleFields === 'object' && styleFields != null, 'invalid styleFields data');
|
|
54
51
|
setSlot(this, 'fields', styleFields);
|
|
55
52
|
}
|
|
56
53
|
DisplayNames.supportedLocalesOf = function (locales, options) {
|
|
57
|
-
return
|
|
54
|
+
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
58
55
|
};
|
|
59
56
|
DisplayNames.__addLocaleData = function () {
|
|
60
57
|
var data = [];
|
|
@@ -77,13 +74,13 @@ var DisplayNames = /** @class */ (function () {
|
|
|
77
74
|
DisplayNames.prototype.of = function (code) {
|
|
78
75
|
checkReceiver(this, 'of');
|
|
79
76
|
var type = getSlot(this, 'type');
|
|
80
|
-
var codeAsString =
|
|
77
|
+
var codeAsString = ToString(code);
|
|
81
78
|
if (!isValidCodeForDisplayNames(type, codeAsString)) {
|
|
82
79
|
throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
|
|
83
80
|
}
|
|
84
|
-
var _a =
|
|
81
|
+
var _a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
|
|
85
82
|
// Canonicalize the case.
|
|
86
|
-
var canonicalCode =
|
|
83
|
+
var canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
|
|
87
84
|
var name;
|
|
88
85
|
if (type === 'language') {
|
|
89
86
|
var languageDisplay = getSlot(this, 'languageDisplay');
|
|
@@ -103,7 +100,7 @@ var DisplayNames = /** @class */ (function () {
|
|
|
103
100
|
};
|
|
104
101
|
DisplayNames.prototype.resolvedOptions = function () {
|
|
105
102
|
checkReceiver(this, 'resolvedOptions');
|
|
106
|
-
return
|
|
103
|
+
return __assign({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback', 'languageDisplay'));
|
|
107
104
|
};
|
|
108
105
|
DisplayNames.getDefaultLocale = function () {
|
|
109
106
|
return DisplayNames.__defaultLocale;
|
|
@@ -114,7 +111,7 @@ var DisplayNames = /** @class */ (function () {
|
|
|
114
111
|
DisplayNames.polyfilled = true;
|
|
115
112
|
return DisplayNames;
|
|
116
113
|
}());
|
|
117
|
-
|
|
114
|
+
export { DisplayNames };
|
|
118
115
|
// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
|
|
119
116
|
function isValidCodeForDisplayNames(type, code) {
|
|
120
117
|
switch (type) {
|
|
@@ -133,12 +130,12 @@ function isValidCodeForDisplayNames(type, code) {
|
|
|
133
130
|
// unicode_script_subtag
|
|
134
131
|
return /^[a-z]{4}$/i.test(code);
|
|
135
132
|
case 'currency':
|
|
136
|
-
return
|
|
133
|
+
return IsWellFormedCurrencyCode(code);
|
|
137
134
|
case 'calendar':
|
|
138
135
|
// unicode locale identifier type
|
|
139
136
|
return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
|
|
140
137
|
case 'dateTimeField':
|
|
141
|
-
return
|
|
138
|
+
return IsValidDateTimeFieldCode(code);
|
|
142
139
|
}
|
|
143
140
|
}
|
|
144
141
|
try {
|
|
@@ -158,15 +155,15 @@ try {
|
|
|
158
155
|
configurable: true,
|
|
159
156
|
});
|
|
160
157
|
}
|
|
161
|
-
catch (
|
|
158
|
+
catch (_a) {
|
|
162
159
|
// Make test 262 compliant
|
|
163
160
|
}
|
|
164
161
|
var __INTERNAL_SLOT_MAP__ = new WeakMap();
|
|
165
162
|
function getSlot(instance, key) {
|
|
166
|
-
return
|
|
163
|
+
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
|
|
167
164
|
}
|
|
168
165
|
function setSlot(instance, key, value) {
|
|
169
|
-
|
|
166
|
+
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
|
|
170
167
|
}
|
|
171
168
|
function checkReceiver(receiver, methodName) {
|
|
172
169
|
if (!(receiver instanceof DisplayNames)) {
|
package/package.json
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-displaynames",
|
|
3
3
|
"description": "Polyfill for: https://tc39.es/proposal-intl-displaynames",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Linjie Ding <pyrocat101@users.noreply.github.com>",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./polyfill.js": "./polyfill.js",
|
|
12
|
+
"./polyfill-force.js": "./polyfill-force.js",
|
|
13
|
+
"./should-polyfill.js": "./should-polyfill.js",
|
|
14
|
+
"./locale-data/*": "./locale-data/*"
|
|
15
|
+
},
|
|
8
16
|
"dependencies": {
|
|
9
17
|
"tslib": "^2.8.0",
|
|
10
|
-
"@formatjs/ecma402-abstract": "
|
|
11
|
-
"@formatjs/intl-localematcher": "0.
|
|
18
|
+
"@formatjs/ecma402-abstract": "3.0.1",
|
|
19
|
+
"@formatjs/intl-localematcher": "0.7.1"
|
|
12
20
|
},
|
|
13
21
|
"devDependencies": {
|
|
14
|
-
"@formatjs/intl-getcanonicallocales": "
|
|
15
|
-
"@formatjs/intl-locale": "
|
|
22
|
+
"@formatjs/intl-getcanonicallocales": "3.0.1",
|
|
23
|
+
"@formatjs/intl-locale": "5.0.1"
|
|
16
24
|
},
|
|
17
25
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
18
26
|
"homepage": "https://github.com/formatjs/formatjs",
|
|
@@ -25,6 +33,5 @@
|
|
|
25
33
|
"localization",
|
|
26
34
|
"polyfill"
|
|
27
35
|
],
|
|
28
|
-
"main": "index.js",
|
|
29
36
|
"repository": "formatjs/formatjs.git"
|
|
30
37
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var _1 = require("./");
|
|
1
|
+
import { DisplayNames } from './index.js';
|
|
4
2
|
Object.defineProperty(Intl, 'DisplayNames', {
|
|
5
|
-
value:
|
|
3
|
+
value: DisplayNames,
|
|
6
4
|
enumerable: false,
|
|
7
5
|
writable: true,
|
|
8
6
|
configurable: true,
|
package/polyfill.iife.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
return value;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
23
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/CanonicalizeLocaleList.js
|
|
24
24
|
function CanonicalizeLocaleList(locales) {
|
|
25
25
|
return Intl.getCanonicalLocales(locales);
|
|
26
26
|
}
|
|
@@ -2385,12 +2385,11 @@
|
|
|
2385
2385
|
var Decimal = P.constructor = clone(DEFAULTS);
|
|
2386
2386
|
LN10 = new Decimal(LN10);
|
|
2387
2387
|
PI = new Decimal(PI);
|
|
2388
|
-
var decimal_default = Decimal;
|
|
2389
2388
|
|
|
2390
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2391
|
-
var TEN = new
|
|
2392
|
-
var ZERO = new
|
|
2393
|
-
var NEGATIVE_ZERO = new
|
|
2389
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
|
|
2390
|
+
var TEN = new Decimal(10);
|
|
2391
|
+
var ZERO = new Decimal(0);
|
|
2392
|
+
var NEGATIVE_ZERO = new Decimal(-0);
|
|
2394
2393
|
|
|
2395
2394
|
// node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
2396
2395
|
var extendStatics = function(d, b) {
|
|
@@ -2424,7 +2423,7 @@
|
|
|
2424
2423
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2425
2424
|
}
|
|
2426
2425
|
|
|
2427
|
-
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/
|
|
2426
|
+
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
2428
2427
|
function memoize(fn, options) {
|
|
2429
2428
|
var cache = options && options.cache ? options.cache : cacheDefault;
|
|
2430
2429
|
var serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -2497,7 +2496,7 @@
|
|
|
2497
2496
|
monadic: strategyMonadic
|
|
2498
2497
|
};
|
|
2499
2498
|
|
|
2500
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2499
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/utils.js
|
|
2501
2500
|
function setInternalSlot(map, pl, field, value) {
|
|
2502
2501
|
if (!map.get(pl)) {
|
|
2503
2502
|
map.set(pl, /* @__PURE__ */ Object.create(null));
|
|
@@ -2581,7 +2580,7 @@
|
|
|
2581
2580
|
strategy: strategies.variadic
|
|
2582
2581
|
});
|
|
2583
2582
|
|
|
2584
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2583
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/262.js
|
|
2585
2584
|
function ToString(o) {
|
|
2586
2585
|
if (typeof o === "symbol") {
|
|
2587
2586
|
throw TypeError("Cannot convert a Symbol value to a string");
|
|
@@ -2600,7 +2599,7 @@
|
|
|
2600
2599
|
var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
|
|
2601
2600
|
var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
|
|
2602
2601
|
|
|
2603
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2602
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOption.js
|
|
2604
2603
|
function GetOption(opts, prop, type, values, fallback) {
|
|
2605
2604
|
if (typeof opts !== "object") {
|
|
2606
2605
|
throw new TypeError("Options must be an object");
|
|
@@ -2626,7 +2625,7 @@
|
|
|
2626
2625
|
return fallback;
|
|
2627
2626
|
}
|
|
2628
2627
|
|
|
2629
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2628
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/GetOptionsObject.js
|
|
2630
2629
|
function GetOptionsObject(options) {
|
|
2631
2630
|
if (typeof options === "undefined") {
|
|
2632
2631
|
return /* @__PURE__ */ Object.create(null);
|
|
@@ -2637,7 +2636,7 @@
|
|
|
2637
2636
|
throw new TypeError("Options must be an object");
|
|
2638
2637
|
}
|
|
2639
2638
|
|
|
2640
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2639
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsSanctionedSimpleUnitIdentifier.js
|
|
2641
2640
|
var SANCTIONED_UNITS = [
|
|
2642
2641
|
"angle-degree",
|
|
2643
2642
|
"area-acre",
|
|
@@ -2688,7 +2687,7 @@
|
|
|
2688
2687
|
}
|
|
2689
2688
|
var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
2690
2689
|
|
|
2691
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2690
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/IsWellFormedCurrencyCode.js
|
|
2692
2691
|
function toUpperCase(str) {
|
|
2693
2692
|
return str.replace(/([a-z])/g, function(_, c) {
|
|
2694
2693
|
return c.toUpperCase();
|
|
@@ -2706,29 +2705,29 @@
|
|
|
2706
2705
|
return true;
|
|
2707
2706
|
}
|
|
2708
2707
|
|
|
2709
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2710
|
-
|
|
2708
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
2709
|
+
Decimal.set({
|
|
2711
2710
|
toExpPos: 100
|
|
2712
2711
|
});
|
|
2713
2712
|
|
|
2714
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2715
|
-
|
|
2713
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
2714
|
+
Decimal.set({
|
|
2716
2715
|
toExpPos: 100
|
|
2717
2716
|
});
|
|
2718
2717
|
|
|
2719
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2718
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
|
|
2720
2719
|
var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
|
2721
2720
|
|
|
2722
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
2721
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/format_to_parts.js
|
|
2723
2722
|
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
2724
2723
|
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
2725
2724
|
|
|
2726
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
2725
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeLocaleList.js
|
|
2727
2726
|
function CanonicalizeLocaleList2(locales) {
|
|
2728
2727
|
return Intl.getCanonicalLocales(locales);
|
|
2729
2728
|
}
|
|
2730
2729
|
|
|
2731
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
2730
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/languageMatching.js
|
|
2732
2731
|
var data = {
|
|
2733
2732
|
supplemental: {
|
|
2734
2733
|
languageMatching: {
|
|
@@ -5350,7 +5349,7 @@
|
|
|
5350
5349
|
}
|
|
5351
5350
|
};
|
|
5352
5351
|
|
|
5353
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
5352
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/regions.generated.js
|
|
5354
5353
|
var regions = {
|
|
5355
5354
|
"001": [
|
|
5356
5355
|
"001",
|
|
@@ -6685,7 +6684,7 @@
|
|
|
6685
6684
|
]
|
|
6686
6685
|
};
|
|
6687
6686
|
|
|
6688
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6687
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
|
|
6689
6688
|
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
6690
6689
|
function invariant2(condition, message, Err) {
|
|
6691
6690
|
if (Err === void 0) {
|
|
@@ -6839,7 +6838,7 @@
|
|
|
6839
6838
|
return result;
|
|
6840
6839
|
}
|
|
6841
6840
|
|
|
6842
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6841
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestFitMatcher.js
|
|
6843
6842
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
6844
6843
|
var foundLocale;
|
|
6845
6844
|
var extension;
|
|
@@ -6864,7 +6863,7 @@
|
|
|
6864
6863
|
};
|
|
6865
6864
|
}
|
|
6866
6865
|
|
|
6867
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6866
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUValue.js
|
|
6868
6867
|
function CanonicalizeUValue(ukey, uvalue) {
|
|
6869
6868
|
var lowerValue = uvalue.toLowerCase();
|
|
6870
6869
|
invariant2(ukey !== void 0, "ukey must be defined");
|
|
@@ -6872,12 +6871,12 @@
|
|
|
6872
6871
|
return canonicalized;
|
|
6873
6872
|
}
|
|
6874
6873
|
|
|
6875
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6874
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.js
|
|
6876
6875
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
6877
6876
|
return Intl.getCanonicalLocales(locale)[0];
|
|
6878
6877
|
}
|
|
6879
6878
|
|
|
6880
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6879
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.js
|
|
6881
6880
|
function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
|
|
6882
6881
|
invariant2(locale.indexOf("-u-") === -1, "Expected locale to not have a Unicode locale extension");
|
|
6883
6882
|
var extension = "-u";
|
|
@@ -6908,7 +6907,7 @@
|
|
|
6908
6907
|
return CanonicalizeUnicodeLocaleId(newLocale);
|
|
6909
6908
|
}
|
|
6910
6909
|
|
|
6911
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6910
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/BestAvailableLocale.js
|
|
6912
6911
|
function BestAvailableLocale(availableLocales, locale) {
|
|
6913
6912
|
var candidate = locale;
|
|
6914
6913
|
while (true) {
|
|
@@ -6926,7 +6925,7 @@
|
|
|
6926
6925
|
}
|
|
6927
6926
|
}
|
|
6928
6927
|
|
|
6929
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6928
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupMatcher.js
|
|
6930
6929
|
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
6931
6930
|
var result = { locale: "" };
|
|
6932
6931
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -6945,7 +6944,7 @@
|
|
|
6945
6944
|
return result;
|
|
6946
6945
|
}
|
|
6947
6946
|
|
|
6948
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6947
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/UnicodeExtensionComponents.js
|
|
6949
6948
|
function UnicodeExtensionComponents(extension) {
|
|
6950
6949
|
invariant2(extension === extension.toLowerCase(), "Expected extension to be lowercase");
|
|
6951
6950
|
invariant2(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
|
|
@@ -6986,7 +6985,7 @@
|
|
|
6986
6985
|
return { attributes, keywords };
|
|
6987
6986
|
}
|
|
6988
6987
|
|
|
6989
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
6988
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
|
|
6990
6989
|
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
6991
6990
|
var _a;
|
|
6992
6991
|
var matcher = options.localeMatcher;
|
|
@@ -7072,7 +7071,7 @@
|
|
|
7072
7071
|
return result;
|
|
7073
7072
|
}
|
|
7074
7073
|
|
|
7075
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7074
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/LookupSupportedLocales.js
|
|
7076
7075
|
function LookupSupportedLocales(availableLocales, requestedLocales) {
|
|
7077
7076
|
var subset = [];
|
|
7078
7077
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -7086,7 +7085,7 @@
|
|
|
7086
7085
|
return subset;
|
|
7087
7086
|
}
|
|
7088
7087
|
|
|
7089
|
-
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/
|
|
7088
|
+
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
|
|
7090
7089
|
function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
7091
7090
|
return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), {
|
|
7092
7091
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
@@ -7095,7 +7094,7 @@
|
|
|
7095
7094
|
}).locale;
|
|
7096
7095
|
}
|
|
7097
7096
|
|
|
7098
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7097
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/SupportedLocales.js
|
|
7099
7098
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
7100
7099
|
var matcher = "best fit";
|
|
7101
7100
|
if (options !== void 0) {
|
|
@@ -7108,7 +7107,7 @@
|
|
|
7108
7107
|
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
7109
7108
|
}
|
|
7110
7109
|
|
|
7111
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7110
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/data.js
|
|
7112
7111
|
var MissingLocaleDataError = (
|
|
7113
7112
|
/** @class */
|
|
7114
7113
|
function(_super) {
|
|
@@ -7122,7 +7121,7 @@
|
|
|
7122
7121
|
}(Error)
|
|
7123
7122
|
);
|
|
7124
7123
|
|
|
7125
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/
|
|
7124
|
+
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/types/date-time.js
|
|
7126
7125
|
var RangePatternType;
|
|
7127
7126
|
(function(RangePatternType2) {
|
|
7128
7127
|
RangePatternType2["startRange"] = "startRange";
|
package/polyfill.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var should_polyfill_1 = require("./should-polyfill");
|
|
5
|
-
if ((0, should_polyfill_1.shouldPolyfill)()) {
|
|
1
|
+
import { DisplayNames } from './index.js';
|
|
2
|
+
import { shouldPolyfill } from './should-polyfill.js';
|
|
3
|
+
if (shouldPolyfill()) {
|
|
6
4
|
Object.defineProperty(Intl, 'DisplayNames', {
|
|
7
|
-
value:
|
|
5
|
+
value: DisplayNames,
|
|
8
6
|
enumerable: false,
|
|
9
7
|
writable: true,
|
|
10
8
|
configurable: true,
|
package/should-polyfill.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports._shouldPolyfillWithoutLocale = _shouldPolyfillWithoutLocale;
|
|
4
|
-
exports.shouldPolyfill = shouldPolyfill;
|
|
5
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
6
|
-
var supported_locales_generated_1 = require("./supported-locales.generated");
|
|
1
|
+
import { match } from '@formatjs/intl-localematcher';
|
|
2
|
+
import { supportedLocales } from './supported-locales.generated.js';
|
|
7
3
|
/**
|
|
8
4
|
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
|
|
9
5
|
*/
|
|
@@ -36,17 +32,17 @@ function supportedLocalesOf(locale) {
|
|
|
36
32
|
return (Intl.DisplayNames.supportedLocalesOf(locales).length ===
|
|
37
33
|
locales.length);
|
|
38
34
|
}
|
|
39
|
-
function _shouldPolyfillWithoutLocale() {
|
|
35
|
+
export function _shouldPolyfillWithoutLocale() {
|
|
40
36
|
return !Intl.DisplayNames || hasMissingICUBug() || hasScriptBug();
|
|
41
37
|
}
|
|
42
|
-
function shouldPolyfill(locale) {
|
|
38
|
+
export function shouldPolyfill(locale) {
|
|
43
39
|
if (locale === void 0) { locale = 'en'; }
|
|
44
40
|
try {
|
|
45
41
|
if (_shouldPolyfillWithoutLocale() || !supportedLocalesOf(locale)) {
|
|
46
|
-
return
|
|
42
|
+
return match([locale], supportedLocales, 'en');
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
catch (
|
|
45
|
+
catch (_a) {
|
|
50
46
|
return true;
|
|
51
47
|
}
|
|
52
48
|
}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.supportedLocales = void 0;
|
|
4
|
-
exports.supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];
|
|
1
|
+
export var supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'calendar' | 'dateTimeField' | 'currency', code: string): string;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList, invariant, IsWellFormedCurrencyCode, } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { IsValidDateTimeFieldCode } from './IsValidDateTimeFieldCode';
|
|
3
|
-
var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
|
|
4
|
-
var ALPHA_4 = /^[a-z]{4}$/i;
|
|
5
|
-
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
|
|
6
|
-
function isUnicodeRegionSubtag(region) {
|
|
7
|
-
return UNICODE_REGION_SUBTAG_REGEX.test(region);
|
|
8
|
-
}
|
|
9
|
-
function isUnicodeScriptSubtag(script) {
|
|
10
|
-
return ALPHA_4.test(script);
|
|
11
|
-
}
|
|
12
|
-
function isUnicodeLocaleIdentifierType(code) {
|
|
13
|
-
return UNICODE_TYPE_REGEX.test(code);
|
|
14
|
-
}
|
|
15
|
-
export function CanonicalCodeForDisplayNames(type, code) {
|
|
16
|
-
if (type === 'language') {
|
|
17
|
-
return CanonicalizeLocaleList([code])[0];
|
|
18
|
-
}
|
|
19
|
-
if (type === 'region') {
|
|
20
|
-
if (!isUnicodeRegionSubtag(code)) {
|
|
21
|
-
throw RangeError('invalid region');
|
|
22
|
-
}
|
|
23
|
-
return code.toUpperCase();
|
|
24
|
-
}
|
|
25
|
-
if (type === 'script') {
|
|
26
|
-
if (!isUnicodeScriptSubtag(code)) {
|
|
27
|
-
throw RangeError('invalid script');
|
|
28
|
-
}
|
|
29
|
-
return "".concat(code[0].toUpperCase()).concat(code.slice(1).toLowerCase());
|
|
30
|
-
}
|
|
31
|
-
if (type === 'calendar') {
|
|
32
|
-
if (!isUnicodeLocaleIdentifierType(code)) {
|
|
33
|
-
throw RangeError('invalid calendar');
|
|
34
|
-
}
|
|
35
|
-
return code.toLowerCase();
|
|
36
|
-
}
|
|
37
|
-
if (type === 'dateTimeField') {
|
|
38
|
-
if (!IsValidDateTimeFieldCode(code)) {
|
|
39
|
-
throw RangeError('invalid dateTimeField');
|
|
40
|
-
}
|
|
41
|
-
return code;
|
|
42
|
-
}
|
|
43
|
-
invariant(type === 'currency', 'invalid type');
|
|
44
|
-
if (!IsWellFormedCurrencyCode(code)) {
|
|
45
|
-
throw RangeError('invalid currency');
|
|
46
|
-
}
|
|
47
|
-
return code.toUpperCase();
|
|
48
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function IsValidDateTimeFieldCode(field: string): boolean;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var CODES_FOR_DATE_TIME_FIELD = [
|
|
2
|
-
'era',
|
|
3
|
-
'year',
|
|
4
|
-
'quarter',
|
|
5
|
-
'month',
|
|
6
|
-
'weekOfYear',
|
|
7
|
-
'weekday',
|
|
8
|
-
'day',
|
|
9
|
-
'dayPeriod',
|
|
10
|
-
'hour',
|
|
11
|
-
'minute',
|
|
12
|
-
'second',
|
|
13
|
-
'timeZoneName',
|
|
14
|
-
];
|
|
15
|
-
export function IsValidDateTimeFieldCode(field) {
|
|
16
|
-
return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
|
|
17
|
-
}
|
package/lib/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DisplayNamesData, DisplayNamesLocaleData } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export interface DisplayNamesOptions {
|
|
3
|
-
localeMatcher?: 'lookup' | 'best fit';
|
|
4
|
-
style?: 'narrow' | 'short' | 'long';
|
|
5
|
-
type: 'language' | 'region' | 'script' | 'currency' | 'calendar' | 'dateTimeField';
|
|
6
|
-
fallback?: 'code' | 'none';
|
|
7
|
-
languageDisplay?: 'dialect' | 'standard';
|
|
8
|
-
}
|
|
9
|
-
export interface DisplayNamesResolvedOptions {
|
|
10
|
-
locale: string;
|
|
11
|
-
style: NonNullable<DisplayNamesOptions['style']>;
|
|
12
|
-
type: NonNullable<DisplayNamesOptions['type']>;
|
|
13
|
-
fallback: NonNullable<DisplayNamesOptions['fallback']>;
|
|
14
|
-
languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>;
|
|
15
|
-
}
|
|
16
|
-
export declare class DisplayNames {
|
|
17
|
-
constructor(locales: string | string[] | undefined, options: DisplayNamesOptions);
|
|
18
|
-
static supportedLocalesOf(locales?: string | string[], options?: Pick<DisplayNamesOptions, 'localeMatcher'>): string[];
|
|
19
|
-
static __addLocaleData(...data: DisplayNamesLocaleData[]): void;
|
|
20
|
-
of(code: string | number | Record<string, unknown>): string | undefined;
|
|
21
|
-
resolvedOptions(): DisplayNamesResolvedOptions;
|
|
22
|
-
static localeData: Record<string, DisplayNamesData | undefined>;
|
|
23
|
-
private static availableLocales;
|
|
24
|
-
private static __defaultLocale;
|
|
25
|
-
private static getDefaultLocale;
|
|
26
|
-
static readonly polyfilled = true;
|
|
27
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { CanonicalizeLocaleList, GetOption, GetOptionsObject, IsWellFormedCurrencyCode, SupportedLocales, ToString, getInternalSlot, getMultiInternalSlots, invariant, setInternalSlot, } from '@formatjs/ecma402-abstract';
|
|
3
|
-
import { CanonicalCodeForDisplayNames } from './abstract/CanonicalCodeForDisplayNames';
|
|
4
|
-
import { IsValidDateTimeFieldCode } from './abstract/IsValidDateTimeFieldCode';
|
|
5
|
-
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
6
|
-
var DisplayNames = /** @class */ (function () {
|
|
7
|
-
function DisplayNames(locales, options) {
|
|
8
|
-
var _newTarget = this.constructor;
|
|
9
|
-
if (_newTarget === undefined) {
|
|
10
|
-
throw TypeError("Constructor Intl.DisplayNames requires 'new'");
|
|
11
|
-
}
|
|
12
|
-
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
13
|
-
options = GetOptionsObject(options);
|
|
14
|
-
var opt = Object.create(null);
|
|
15
|
-
var localeData = DisplayNames.localeData;
|
|
16
|
-
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
17
|
-
opt.localeMatcher = matcher;
|
|
18
|
-
var r = ResolveLocale(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], // there is no relevantExtensionKeys
|
|
19
|
-
DisplayNames.localeData, DisplayNames.getDefaultLocale);
|
|
20
|
-
var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
|
|
21
|
-
setSlot(this, 'style', style);
|
|
22
|
-
var type = GetOption(options, 'type', 'string', ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'], undefined);
|
|
23
|
-
if (type === undefined) {
|
|
24
|
-
throw TypeError("Intl.DisplayNames constructor requires \"type\" option");
|
|
25
|
-
}
|
|
26
|
-
setSlot(this, 'type', type);
|
|
27
|
-
var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
|
|
28
|
-
setSlot(this, 'fallback', fallback);
|
|
29
|
-
setSlot(this, 'locale', r.locale);
|
|
30
|
-
var dataLocale = r.dataLocale;
|
|
31
|
-
var dataLocaleData = localeData[dataLocale];
|
|
32
|
-
invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
|
|
33
|
-
setSlot(this, 'localeData', dataLocaleData);
|
|
34
|
-
invariant(dataLocaleData !== undefined, "locale data for ".concat(r.locale, " does not exist."));
|
|
35
|
-
var types = dataLocaleData.types;
|
|
36
|
-
invariant(typeof types === 'object' && types != null, 'invalid types data');
|
|
37
|
-
var typeFields = types[type];
|
|
38
|
-
invariant(typeof typeFields === 'object' && typeFields != null, 'invalid typeFields data');
|
|
39
|
-
var languageDisplay = GetOption(options, 'languageDisplay', 'string', ['dialect', 'standard'], 'dialect');
|
|
40
|
-
if (type === 'language') {
|
|
41
|
-
setSlot(this, 'languageDisplay', languageDisplay);
|
|
42
|
-
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
|
|
43
|
-
var typeFields_1 = types[type][languageDisplay];
|
|
44
|
-
invariant(typeof typeFields_1 === 'object' && typeFields_1 != null, 'invalid language typeFields data');
|
|
45
|
-
}
|
|
46
|
-
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
|
|
47
|
-
var styleFields = type === 'language'
|
|
48
|
-
? types[type][languageDisplay][style]
|
|
49
|
-
: types[type][style];
|
|
50
|
-
invariant(typeof styleFields === 'object' && styleFields != null, 'invalid styleFields data');
|
|
51
|
-
setSlot(this, 'fields', styleFields);
|
|
52
|
-
}
|
|
53
|
-
DisplayNames.supportedLocalesOf = function (locales, options) {
|
|
54
|
-
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
55
|
-
};
|
|
56
|
-
DisplayNames.__addLocaleData = function () {
|
|
57
|
-
var data = [];
|
|
58
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
59
|
-
data[_i] = arguments[_i];
|
|
60
|
-
}
|
|
61
|
-
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
|
|
62
|
-
var _b = data_1[_a], d = _b.data, locale = _b.locale;
|
|
63
|
-
var minimizedLocale = new Intl.Locale(locale)
|
|
64
|
-
.minimize()
|
|
65
|
-
.toString();
|
|
66
|
-
DisplayNames.localeData[locale] = DisplayNames.localeData[minimizedLocale] = d;
|
|
67
|
-
DisplayNames.availableLocales.add(minimizedLocale);
|
|
68
|
-
DisplayNames.availableLocales.add(locale);
|
|
69
|
-
if (!DisplayNames.__defaultLocale) {
|
|
70
|
-
DisplayNames.__defaultLocale = minimizedLocale;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
DisplayNames.prototype.of = function (code) {
|
|
75
|
-
checkReceiver(this, 'of');
|
|
76
|
-
var type = getSlot(this, 'type');
|
|
77
|
-
var codeAsString = ToString(code);
|
|
78
|
-
if (!isValidCodeForDisplayNames(type, codeAsString)) {
|
|
79
|
-
throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
|
|
80
|
-
}
|
|
81
|
-
var _a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
|
|
82
|
-
// Canonicalize the case.
|
|
83
|
-
var canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
|
|
84
|
-
var name;
|
|
85
|
-
if (type === 'language') {
|
|
86
|
-
var languageDisplay = getSlot(this, 'languageDisplay');
|
|
87
|
-
name = getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// All the other types
|
|
91
|
-
var typesData = localeData.types[type];
|
|
92
|
-
name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
93
|
-
}
|
|
94
|
-
if (name !== undefined) {
|
|
95
|
-
return name;
|
|
96
|
-
}
|
|
97
|
-
if (fallback === 'code') {
|
|
98
|
-
return codeAsString;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
DisplayNames.prototype.resolvedOptions = function () {
|
|
102
|
-
checkReceiver(this, 'resolvedOptions');
|
|
103
|
-
return __assign({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback', 'languageDisplay'));
|
|
104
|
-
};
|
|
105
|
-
DisplayNames.getDefaultLocale = function () {
|
|
106
|
-
return DisplayNames.__defaultLocale;
|
|
107
|
-
};
|
|
108
|
-
DisplayNames.localeData = {};
|
|
109
|
-
DisplayNames.availableLocales = new Set();
|
|
110
|
-
DisplayNames.__defaultLocale = '';
|
|
111
|
-
DisplayNames.polyfilled = true;
|
|
112
|
-
return DisplayNames;
|
|
113
|
-
}());
|
|
114
|
-
export { DisplayNames };
|
|
115
|
-
// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
|
|
116
|
-
function isValidCodeForDisplayNames(type, code) {
|
|
117
|
-
switch (type) {
|
|
118
|
-
case 'language':
|
|
119
|
-
// subset of unicode_language_id
|
|
120
|
-
// languageCode ["-" scriptCode] ["-" regionCode] *("-" variant)
|
|
121
|
-
// where:
|
|
122
|
-
// - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.
|
|
123
|
-
// - scriptCode is should be an ISO-15924 four letters script code
|
|
124
|
-
// - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.
|
|
125
|
-
return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(code);
|
|
126
|
-
case 'region':
|
|
127
|
-
// unicode_region_subtag
|
|
128
|
-
return /^([a-z]{2}|\d{3})$/i.test(code);
|
|
129
|
-
case 'script':
|
|
130
|
-
// unicode_script_subtag
|
|
131
|
-
return /^[a-z]{4}$/i.test(code);
|
|
132
|
-
case 'currency':
|
|
133
|
-
return IsWellFormedCurrencyCode(code);
|
|
134
|
-
case 'calendar':
|
|
135
|
-
// unicode locale identifier type
|
|
136
|
-
return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
|
|
137
|
-
case 'dateTimeField':
|
|
138
|
-
return IsValidDateTimeFieldCode(code);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
// IE11 does not have Symbol
|
|
143
|
-
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
144
|
-
Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
|
|
145
|
-
value: 'Intl.DisplayNames',
|
|
146
|
-
configurable: true,
|
|
147
|
-
enumerable: false,
|
|
148
|
-
writable: false,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
Object.defineProperty(DisplayNames, 'length', {
|
|
152
|
-
value: 2,
|
|
153
|
-
writable: false,
|
|
154
|
-
enumerable: false,
|
|
155
|
-
configurable: true,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
catch (e) {
|
|
159
|
-
// Make test 262 compliant
|
|
160
|
-
}
|
|
161
|
-
var __INTERNAL_SLOT_MAP__ = new WeakMap();
|
|
162
|
-
function getSlot(instance, key) {
|
|
163
|
-
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
|
|
164
|
-
}
|
|
165
|
-
function setSlot(instance, key, value) {
|
|
166
|
-
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
|
|
167
|
-
}
|
|
168
|
-
function checkReceiver(receiver, methodName) {
|
|
169
|
-
if (!(receiver instanceof DisplayNames)) {
|
|
170
|
-
throw TypeError("Method Intl.DisplayNames.prototype.".concat(methodName, " called on incompatible receiver"));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback) {
|
|
174
|
-
// First, try to get the name using the canonicalCode
|
|
175
|
-
var typesData = localeData.types.language[languageDisplay];
|
|
176
|
-
var name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
177
|
-
if (name === undefined) {
|
|
178
|
-
// If no name has been found using the canonicalCode,
|
|
179
|
-
// check if the latter contains a region sub tag
|
|
180
|
-
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
|
|
181
|
-
if (regionMatch) {
|
|
182
|
-
// Extract the language and region sub tags
|
|
183
|
-
var languageSubTag = canonicalCode.substring(0, regionMatch.index) +
|
|
184
|
-
canonicalCode.substring(regionMatch.index + regionMatch[0].length);
|
|
185
|
-
var regionSubTag = regionMatch[1];
|
|
186
|
-
// Let's try again using languageSubTag this time
|
|
187
|
-
var name_1 = typesData[style][languageSubTag] || typesData.long[languageSubTag];
|
|
188
|
-
// If a name has been found and a region sub tag exists,
|
|
189
|
-
// compose them together or use the code fallback
|
|
190
|
-
if (name_1 !== undefined && regionSubTag) {
|
|
191
|
-
// Retrieve region display names
|
|
192
|
-
var regionsData = localeData.types.region;
|
|
193
|
-
var regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
|
|
194
|
-
if (regionDisplayName || fallback === 'code') {
|
|
195
|
-
// Interpolate into locale-specific pattern.
|
|
196
|
-
var pattern = localeData.patterns.locale;
|
|
197
|
-
return pattern
|
|
198
|
-
.replace('{0}', name_1)
|
|
199
|
-
.replace('{1}', regionDisplayName || regionSubTag);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
return name_1;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
return name;
|
|
209
|
-
}
|
|
210
|
-
}
|
package/lib/polyfill-force.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill-force.js
DELETED
package/lib/polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/polyfill.js
DELETED
package/lib/should-polyfill.d.ts
DELETED
package/lib/should-polyfill.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { match } from '@formatjs/intl-localematcher';
|
|
2
|
-
import { supportedLocales } from './supported-locales.generated';
|
|
3
|
-
/**
|
|
4
|
-
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
|
|
5
|
-
*/
|
|
6
|
-
function hasMissingICUBug() {
|
|
7
|
-
var DisplayNames = Intl.DisplayNames;
|
|
8
|
-
if (DisplayNames && !DisplayNames.polyfilled) {
|
|
9
|
-
return (new DisplayNames(['en'], {
|
|
10
|
-
type: 'region',
|
|
11
|
-
}).of('CA') === 'CA');
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* https://bugs.chromium.org/p/chromium/issues/detail?id=1176979
|
|
17
|
-
*/
|
|
18
|
-
function hasScriptBug() {
|
|
19
|
-
var DisplayNames = Intl.DisplayNames;
|
|
20
|
-
if (DisplayNames && !DisplayNames.polyfilled) {
|
|
21
|
-
return (new DisplayNames(['en'], {
|
|
22
|
-
type: 'script',
|
|
23
|
-
}).of('arab') !== 'Arabic');
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
function supportedLocalesOf(locale) {
|
|
28
|
-
if (!locale) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
var locales = Array.isArray(locale) ? locale : [locale];
|
|
32
|
-
return (Intl.DisplayNames.supportedLocalesOf(locales).length ===
|
|
33
|
-
locales.length);
|
|
34
|
-
}
|
|
35
|
-
export function _shouldPolyfillWithoutLocale() {
|
|
36
|
-
return !Intl.DisplayNames || hasMissingICUBug() || hasScriptBug();
|
|
37
|
-
}
|
|
38
|
-
export function shouldPolyfill(locale) {
|
|
39
|
-
if (locale === void 0) { locale = 'en'; }
|
|
40
|
-
try {
|
|
41
|
-
if (_shouldPolyfillWithoutLocale() || !supportedLocalesOf(locale)) {
|
|
42
|
-
return match([locale], supportedLocales, 'en');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const supportedLocales: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];
|