@formatjs/intl-displaynames 7.3.1 → 7.3.3
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/index.d.ts +99 -24
- package/index.js +291 -92
- package/index.js.map +1 -0
- package/package.json +4 -5
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +396 -2
- package/polyfill-force.js.map +1 -0
- package/polyfill.d.ts +1 -1
- package/polyfill.iife.js +4146 -5514
- package/polyfill.js +1014 -3
- package/polyfill.js.map +1 -0
- package/should-polyfill.d.ts +6 -2
- package/should-polyfill.js +586 -15
- package/should-polyfill.js.map +1 -0
- package/abstract/CanonicalCodeForDisplayNames.d.ts +0 -1
- package/abstract/CanonicalCodeForDisplayNames.js +0 -48
- package/abstract/IsValidDateTimeFieldCode.d.ts +0 -1
- package/abstract/IsValidDateTimeFieldCode.js +0 -17
- package/supported-locales.generated.d.ts +0 -1
- package/supported-locales.generated.js +0 -573
package/polyfill.js
CHANGED
|
@@ -1,5 +1,1014 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { LookupSupportedLocales, ResolveLocale, match } from "@formatjs/intl-localematcher";
|
|
2
|
+
//#region packages/ecma262-abstract/ToString.js
|
|
3
|
+
/**
|
|
4
|
+
* https://tc39.es/ecma262/#sec-tostring
|
|
5
|
+
*/
|
|
6
|
+
function ToString(o) {
|
|
7
|
+
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
|
|
8
|
+
return String(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
12
|
+
/**
|
|
13
|
+
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
14
|
+
* @param locales
|
|
15
|
+
*/
|
|
16
|
+
function CanonicalizeLocaleList(locales) {
|
|
17
|
+
return Intl.getCanonicalLocales(locales);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region packages/ecma402-abstract/GetOption.js
|
|
21
|
+
/**
|
|
22
|
+
* https://tc39.es/ecma402/#sec-getoption
|
|
23
|
+
* @param opts
|
|
24
|
+
* @param prop
|
|
25
|
+
* @param type
|
|
26
|
+
* @param values
|
|
27
|
+
* @param fallback
|
|
28
|
+
*/
|
|
29
|
+
function GetOption(opts, prop, type, values, fallback) {
|
|
30
|
+
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
31
|
+
let value = opts[prop];
|
|
32
|
+
if (value !== void 0) {
|
|
33
|
+
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
34
|
+
if (type === "boolean") value = Boolean(value);
|
|
35
|
+
if (type === "string") value = ToString(value);
|
|
36
|
+
if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return fallback;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region packages/ecma402-abstract/GetOptionsObject.js
|
|
43
|
+
/**
|
|
44
|
+
* https://tc39.es/ecma402/#sec-getoptionsobject
|
|
45
|
+
* @param options
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function GetOptionsObject(options) {
|
|
49
|
+
if (typeof options === "undefined") return Object.create(null);
|
|
50
|
+
if (typeof options === "object") return options;
|
|
51
|
+
throw new TypeError("Options must be an object");
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/ecma402-abstract/IsWellFormedCurrencyCode.js
|
|
55
|
+
/**
|
|
56
|
+
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
57
|
+
* @param str string to convert
|
|
58
|
+
*/
|
|
59
|
+
function toUpperCase(str) {
|
|
60
|
+
return str.replace(/([a-z])/g, (_, c) => c.toUpperCase());
|
|
61
|
+
}
|
|
62
|
+
const NOT_A_Z_REGEX = /[^A-Z]/;
|
|
63
|
+
/**
|
|
64
|
+
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
|
|
65
|
+
*/
|
|
66
|
+
function IsWellFormedCurrencyCode(currency) {
|
|
67
|
+
currency = toUpperCase(currency);
|
|
68
|
+
if (currency.length !== 3) return false;
|
|
69
|
+
if (NOT_A_Z_REGEX.test(currency)) return false;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region packages/ecma262-abstract/ToObject.js
|
|
74
|
+
/**
|
|
75
|
+
* https://tc39.es/ecma262/#sec-toobject
|
|
76
|
+
*/
|
|
77
|
+
function ToObject(arg) {
|
|
78
|
+
if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
|
|
79
|
+
return Object(arg);
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region packages/ecma402-abstract/SupportedLocales.js
|
|
83
|
+
/**
|
|
84
|
+
* https://tc39.es/ecma402/#sec-supportedlocales
|
|
85
|
+
* @param availableLocales
|
|
86
|
+
* @param requestedLocales
|
|
87
|
+
* @param options
|
|
88
|
+
*/
|
|
89
|
+
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
90
|
+
let matcher = "best fit";
|
|
91
|
+
if (options !== void 0) {
|
|
92
|
+
options = ToObject(options);
|
|
93
|
+
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
94
|
+
}
|
|
95
|
+
if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
96
|
+
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
100
|
+
function memoize(fn, options) {
|
|
101
|
+
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
102
|
+
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
103
|
+
return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
|
|
104
|
+
cache,
|
|
105
|
+
serializer
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function isPrimitive(value) {
|
|
109
|
+
return value == null || typeof value === "number" || typeof value === "boolean";
|
|
110
|
+
}
|
|
111
|
+
function monadic(fn, cache, serializer, arg) {
|
|
112
|
+
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
113
|
+
let computedValue = cache.get(cacheKey);
|
|
114
|
+
if (typeof computedValue === "undefined") {
|
|
115
|
+
computedValue = fn.call(this, arg);
|
|
116
|
+
cache.set(cacheKey, computedValue);
|
|
117
|
+
}
|
|
118
|
+
return computedValue;
|
|
119
|
+
}
|
|
120
|
+
function variadic(fn, cache, serializer) {
|
|
121
|
+
const args = Array.prototype.slice.call(arguments, 3);
|
|
122
|
+
const cacheKey = serializer(args);
|
|
123
|
+
let computedValue = cache.get(cacheKey);
|
|
124
|
+
if (typeof computedValue === "undefined") {
|
|
125
|
+
computedValue = fn.apply(this, args);
|
|
126
|
+
cache.set(cacheKey, computedValue);
|
|
127
|
+
}
|
|
128
|
+
return computedValue;
|
|
129
|
+
}
|
|
130
|
+
function assemble(fn, context, strategy, cache, serialize) {
|
|
131
|
+
return strategy.bind(context, fn, cache, serialize);
|
|
132
|
+
}
|
|
133
|
+
function strategyDefault(fn, options) {
|
|
134
|
+
const strategy = fn.length === 1 ? monadic : variadic;
|
|
135
|
+
return assemble(fn, this, strategy, options.cache.create(), options.serializer);
|
|
136
|
+
}
|
|
137
|
+
function strategyVariadic(fn, options) {
|
|
138
|
+
return assemble(fn, this, variadic, options.cache.create(), options.serializer);
|
|
139
|
+
}
|
|
140
|
+
function strategyMonadic(fn, options) {
|
|
141
|
+
return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
|
142
|
+
}
|
|
143
|
+
const serializerDefault = function() {
|
|
144
|
+
return JSON.stringify(arguments);
|
|
145
|
+
};
|
|
146
|
+
var ObjectWithoutPrototypeCache = class {
|
|
147
|
+
constructor() {
|
|
148
|
+
this.cache = Object.create(null);
|
|
149
|
+
}
|
|
150
|
+
get(key) {
|
|
151
|
+
return this.cache[key];
|
|
152
|
+
}
|
|
153
|
+
set(key, value) {
|
|
154
|
+
this.cache[key] = value;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const cacheDefault = { create: function create() {
|
|
158
|
+
return new ObjectWithoutPrototypeCache();
|
|
159
|
+
} };
|
|
160
|
+
const strategies = {
|
|
161
|
+
variadic: strategyVariadic,
|
|
162
|
+
monadic: strategyMonadic
|
|
163
|
+
};
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region packages/ecma402-abstract/utils.js
|
|
166
|
+
function setInternalSlot(map, pl, field, value) {
|
|
167
|
+
if (!map.get(pl)) map.set(pl, Object.create(null));
|
|
168
|
+
const slots = map.get(pl);
|
|
169
|
+
slots[field] = value;
|
|
170
|
+
}
|
|
171
|
+
function getInternalSlot(map, pl, field) {
|
|
172
|
+
return getMultiInternalSlots(map, pl, field)[field];
|
|
173
|
+
}
|
|
174
|
+
function getMultiInternalSlots(map, pl, ...fields) {
|
|
175
|
+
const slots = map.get(pl);
|
|
176
|
+
if (!slots) throw new TypeError(`${pl} InternalSlot has not been initialized`);
|
|
177
|
+
return fields.reduce((all, f) => {
|
|
178
|
+
all[f] = slots[f];
|
|
179
|
+
return all;
|
|
180
|
+
}, Object.create(null));
|
|
181
|
+
}
|
|
182
|
+
function invariant(condition, message, Err = Error) {
|
|
183
|
+
if (!condition) throw new Err(message);
|
|
184
|
+
}
|
|
185
|
+
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
186
|
+
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
|
|
187
|
+
memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });
|
|
188
|
+
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region packages/ecma402-abstract/DisplayNames/IsValidDateTimeFieldCode.js
|
|
191
|
+
const CODES_FOR_DATE_TIME_FIELD = [
|
|
192
|
+
"era",
|
|
193
|
+
"year",
|
|
194
|
+
"quarter",
|
|
195
|
+
"month",
|
|
196
|
+
"weekOfYear",
|
|
197
|
+
"weekday",
|
|
198
|
+
"day",
|
|
199
|
+
"dayPeriod",
|
|
200
|
+
"hour",
|
|
201
|
+
"minute",
|
|
202
|
+
"second",
|
|
203
|
+
"timeZoneName"
|
|
204
|
+
];
|
|
205
|
+
function IsValidDateTimeFieldCode(field) {
|
|
206
|
+
return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region packages/ecma402-abstract/DisplayNames/CanonicalCodeForDisplayNames.js
|
|
210
|
+
const UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
|
|
211
|
+
const ALPHA_4 = /^[a-z]{4}$/i;
|
|
212
|
+
const UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
|
|
213
|
+
function isUnicodeRegionSubtag(region) {
|
|
214
|
+
return UNICODE_REGION_SUBTAG_REGEX.test(region);
|
|
215
|
+
}
|
|
216
|
+
function isUnicodeScriptSubtag(script) {
|
|
217
|
+
return ALPHA_4.test(script);
|
|
218
|
+
}
|
|
219
|
+
function isUnicodeLocaleIdentifierType(code) {
|
|
220
|
+
return UNICODE_TYPE_REGEX.test(code);
|
|
221
|
+
}
|
|
222
|
+
function CanonicalCodeForDisplayNames(type, code) {
|
|
223
|
+
if (type === "language") return CanonicalizeLocaleList([code])[0];
|
|
224
|
+
if (type === "region") {
|
|
225
|
+
if (!isUnicodeRegionSubtag(code)) throw RangeError("invalid region");
|
|
226
|
+
return code.toUpperCase();
|
|
227
|
+
}
|
|
228
|
+
if (type === "script") {
|
|
229
|
+
if (!isUnicodeScriptSubtag(code)) throw RangeError("invalid script");
|
|
230
|
+
return `${code[0].toUpperCase()}${code.slice(1).toLowerCase()}`;
|
|
231
|
+
}
|
|
232
|
+
if (type === "calendar") {
|
|
233
|
+
if (!isUnicodeLocaleIdentifierType(code)) throw RangeError("invalid calendar");
|
|
234
|
+
return code.toLowerCase();
|
|
235
|
+
}
|
|
236
|
+
if (type === "dateTimeField") {
|
|
237
|
+
if (!IsValidDateTimeFieldCode(code)) throw RangeError("invalid dateTimeField");
|
|
238
|
+
return code;
|
|
239
|
+
}
|
|
240
|
+
invariant(type === "currency", "invalid type");
|
|
241
|
+
if (!IsWellFormedCurrencyCode(code)) throw RangeError("invalid currency");
|
|
242
|
+
return code.toUpperCase();
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region packages/intl-displaynames/index.ts
|
|
246
|
+
var DisplayNames = class DisplayNames {
|
|
247
|
+
constructor(locales, options) {
|
|
248
|
+
if (new.target === void 0) throw TypeError(`Constructor Intl.DisplayNames requires 'new'`);
|
|
249
|
+
const requestedLocales = CanonicalizeLocaleList(locales);
|
|
250
|
+
options = GetOptionsObject(options);
|
|
251
|
+
const opt = Object.create(null);
|
|
252
|
+
const { localeData } = DisplayNames;
|
|
253
|
+
opt.localeMatcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
254
|
+
const r = ResolveLocale(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], DisplayNames.localeData, DisplayNames.getDefaultLocale);
|
|
255
|
+
const style = GetOption(options, "style", "string", [
|
|
256
|
+
"narrow",
|
|
257
|
+
"short",
|
|
258
|
+
"long"
|
|
259
|
+
], "long");
|
|
260
|
+
setSlot(this, "style", style);
|
|
261
|
+
const type = GetOption(options, "type", "string", [
|
|
262
|
+
"language",
|
|
263
|
+
"region",
|
|
264
|
+
"script",
|
|
265
|
+
"currency",
|
|
266
|
+
"calendar",
|
|
267
|
+
"dateTimeField"
|
|
268
|
+
], void 0);
|
|
269
|
+
if (type === void 0) throw TypeError(`Intl.DisplayNames constructor requires "type" option`);
|
|
270
|
+
setSlot(this, "type", type);
|
|
271
|
+
const fallback = GetOption(options, "fallback", "string", ["code", "none"], "code");
|
|
272
|
+
setSlot(this, "fallback", fallback);
|
|
273
|
+
setSlot(this, "locale", r.locale);
|
|
274
|
+
const { dataLocale } = r;
|
|
275
|
+
const dataLocaleData = localeData[dataLocale];
|
|
276
|
+
invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`);
|
|
277
|
+
setSlot(this, "localeData", dataLocaleData);
|
|
278
|
+
invariant(dataLocaleData !== void 0, `locale data for ${r.locale} does not exist.`);
|
|
279
|
+
const { types } = dataLocaleData;
|
|
280
|
+
invariant(typeof types === "object" && types != null, "invalid types data");
|
|
281
|
+
const typeFields = types[type];
|
|
282
|
+
invariant(typeof typeFields === "object" && typeFields != null, "invalid typeFields data");
|
|
283
|
+
const languageDisplay = GetOption(options, "languageDisplay", "string", ["dialect", "standard"], "dialect");
|
|
284
|
+
if (type === "language") {
|
|
285
|
+
setSlot(this, "languageDisplay", languageDisplay);
|
|
286
|
+
const typeFields = types[type][languageDisplay];
|
|
287
|
+
invariant(typeof typeFields === "object" && typeFields != null, "invalid language typeFields data");
|
|
288
|
+
}
|
|
289
|
+
const styleFields = type === "language" ? types[type][languageDisplay][style] : types[type][style];
|
|
290
|
+
invariant(typeof styleFields === "object" && styleFields != null, "invalid styleFields data");
|
|
291
|
+
setSlot(this, "fields", styleFields);
|
|
292
|
+
}
|
|
293
|
+
static supportedLocalesOf(locales, options) {
|
|
294
|
+
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
|
|
295
|
+
}
|
|
296
|
+
static __addLocaleData(...data) {
|
|
297
|
+
for (const { data: d, locale } of data) {
|
|
298
|
+
const minimizedLocale = new Intl.Locale(locale).minimize().toString();
|
|
299
|
+
DisplayNames.localeData[locale] = DisplayNames.localeData[minimizedLocale] = d;
|
|
300
|
+
DisplayNames.availableLocales.add(minimizedLocale);
|
|
301
|
+
DisplayNames.availableLocales.add(locale);
|
|
302
|
+
if (!DisplayNames.__defaultLocale) DisplayNames.__defaultLocale = minimizedLocale;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
of(code) {
|
|
306
|
+
checkReceiver(this, "of");
|
|
307
|
+
const type = getSlot(this, "type");
|
|
308
|
+
const codeAsString = ToString(code);
|
|
309
|
+
if (!isValidCodeForDisplayNames(type, codeAsString)) throw RangeError("invalid code for Intl.DisplayNames.prototype.of");
|
|
310
|
+
const { localeData, style, fallback } = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, "localeData", "style", "fallback");
|
|
311
|
+
let canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
|
|
312
|
+
let name;
|
|
313
|
+
if (type === "language") name = getNameForTypeLanguage(getSlot(this, "languageDisplay"), localeData, style, canonicalCode, fallback);
|
|
314
|
+
else {
|
|
315
|
+
const typesData = localeData.types[type];
|
|
316
|
+
name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
317
|
+
}
|
|
318
|
+
if (name !== void 0) return name;
|
|
319
|
+
if (fallback === "code") return codeAsString;
|
|
320
|
+
}
|
|
321
|
+
resolvedOptions() {
|
|
322
|
+
checkReceiver(this, "resolvedOptions");
|
|
323
|
+
return { ...getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, "locale", "style", "type", "fallback", "languageDisplay") };
|
|
324
|
+
}
|
|
325
|
+
static {
|
|
326
|
+
this.localeData = {};
|
|
327
|
+
}
|
|
328
|
+
static {
|
|
329
|
+
this.availableLocales = /* @__PURE__ */ new Set();
|
|
330
|
+
}
|
|
331
|
+
static {
|
|
332
|
+
this.__defaultLocale = "";
|
|
333
|
+
}
|
|
334
|
+
static getDefaultLocale() {
|
|
335
|
+
return DisplayNames.__defaultLocale;
|
|
336
|
+
}
|
|
337
|
+
static {
|
|
338
|
+
this.polyfilled = true;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
function isValidCodeForDisplayNames(type, code) {
|
|
342
|
+
switch (type) {
|
|
343
|
+
case "language": 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);
|
|
344
|
+
case "region": return /^([a-z]{2}|\d{3})$/i.test(code);
|
|
345
|
+
case "script": return /^[a-z]{4}$/i.test(code);
|
|
346
|
+
case "currency": return IsWellFormedCurrencyCode(code);
|
|
347
|
+
case "calendar": return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
|
|
348
|
+
case "dateTimeField": return IsValidDateTimeFieldCode(code);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
if (typeof Symbol !== "undefined" && Symbol.toStringTag) Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
|
|
353
|
+
value: "Intl.DisplayNames",
|
|
354
|
+
configurable: true,
|
|
355
|
+
enumerable: false,
|
|
356
|
+
writable: false
|
|
357
|
+
});
|
|
358
|
+
Object.defineProperty(DisplayNames, "length", {
|
|
359
|
+
value: 2,
|
|
360
|
+
writable: false,
|
|
361
|
+
enumerable: false,
|
|
362
|
+
configurable: true
|
|
363
|
+
});
|
|
364
|
+
} catch {}
|
|
365
|
+
const __INTERNAL_SLOT_MAP__ = /* @__PURE__ */ new WeakMap();
|
|
366
|
+
function getSlot(instance, key) {
|
|
367
|
+
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
|
|
368
|
+
}
|
|
369
|
+
function setSlot(instance, key, value) {
|
|
370
|
+
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
|
|
371
|
+
}
|
|
372
|
+
function checkReceiver(receiver, methodName) {
|
|
373
|
+
if (!(receiver instanceof DisplayNames)) throw TypeError(`Method Intl.DisplayNames.prototype.${methodName} called on incompatible receiver`);
|
|
374
|
+
}
|
|
375
|
+
function getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback) {
|
|
376
|
+
const typesData = localeData.types.language[languageDisplay];
|
|
377
|
+
const name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
|
|
378
|
+
if (name === void 0) {
|
|
379
|
+
const regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
|
|
380
|
+
if (regionMatch) {
|
|
381
|
+
const languageSubTag = canonicalCode.substring(0, regionMatch.index) + canonicalCode.substring(regionMatch.index + regionMatch[0].length);
|
|
382
|
+
const regionSubTag = regionMatch[1];
|
|
383
|
+
const name = typesData[style][languageSubTag] || typesData.long[languageSubTag];
|
|
384
|
+
if (name !== void 0 && regionSubTag) {
|
|
385
|
+
const regionsData = localeData.types.region;
|
|
386
|
+
const regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
|
|
387
|
+
if (regionDisplayName || fallback === "code") return localeData.patterns.locale.replace("{0}", name).replace("{1}", regionDisplayName || regionSubTag);
|
|
388
|
+
} else return name;
|
|
389
|
+
}
|
|
390
|
+
} else return name;
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/intl-displaynames.js
|
|
394
|
+
const supportedLocales = [
|
|
395
|
+
"af",
|
|
396
|
+
"af-NA",
|
|
397
|
+
"agq",
|
|
398
|
+
"ak",
|
|
399
|
+
"am",
|
|
400
|
+
"ar",
|
|
401
|
+
"ar-AE",
|
|
402
|
+
"ar-BH",
|
|
403
|
+
"ar-DJ",
|
|
404
|
+
"ar-DZ",
|
|
405
|
+
"ar-EG",
|
|
406
|
+
"ar-EH",
|
|
407
|
+
"ar-ER",
|
|
408
|
+
"ar-IL",
|
|
409
|
+
"ar-IQ",
|
|
410
|
+
"ar-JO",
|
|
411
|
+
"ar-KM",
|
|
412
|
+
"ar-KW",
|
|
413
|
+
"ar-LB",
|
|
414
|
+
"ar-LY",
|
|
415
|
+
"ar-MA",
|
|
416
|
+
"ar-MR",
|
|
417
|
+
"ar-OM",
|
|
418
|
+
"ar-PS",
|
|
419
|
+
"ar-QA",
|
|
420
|
+
"ar-SA",
|
|
421
|
+
"ar-SD",
|
|
422
|
+
"ar-SO",
|
|
423
|
+
"ar-SS",
|
|
424
|
+
"ar-SY",
|
|
425
|
+
"ar-TD",
|
|
426
|
+
"ar-TN",
|
|
427
|
+
"ar-YE",
|
|
428
|
+
"as",
|
|
429
|
+
"asa",
|
|
430
|
+
"ast",
|
|
431
|
+
"az",
|
|
432
|
+
"az-Cyrl",
|
|
433
|
+
"az-Latn",
|
|
434
|
+
"bas",
|
|
435
|
+
"be",
|
|
436
|
+
"be-tarask",
|
|
437
|
+
"bem",
|
|
438
|
+
"bez",
|
|
439
|
+
"bg",
|
|
440
|
+
"bm",
|
|
441
|
+
"bn",
|
|
442
|
+
"bn-IN",
|
|
443
|
+
"bo",
|
|
444
|
+
"bo-IN",
|
|
445
|
+
"br",
|
|
446
|
+
"brx",
|
|
447
|
+
"bs",
|
|
448
|
+
"bs-Cyrl",
|
|
449
|
+
"bs-Latn",
|
|
450
|
+
"ca",
|
|
451
|
+
"ca-AD",
|
|
452
|
+
"ca-ES-valencia",
|
|
453
|
+
"ca-FR",
|
|
454
|
+
"ca-IT",
|
|
455
|
+
"ccp",
|
|
456
|
+
"ccp-IN",
|
|
457
|
+
"ce",
|
|
458
|
+
"ceb",
|
|
459
|
+
"cgg",
|
|
460
|
+
"chr",
|
|
461
|
+
"ckb",
|
|
462
|
+
"ckb-IR",
|
|
463
|
+
"cs",
|
|
464
|
+
"cy",
|
|
465
|
+
"da",
|
|
466
|
+
"da-GL",
|
|
467
|
+
"dav",
|
|
468
|
+
"de",
|
|
469
|
+
"de-AT",
|
|
470
|
+
"de-BE",
|
|
471
|
+
"de-CH",
|
|
472
|
+
"de-IT",
|
|
473
|
+
"de-LI",
|
|
474
|
+
"de-LU",
|
|
475
|
+
"dje",
|
|
476
|
+
"doi",
|
|
477
|
+
"dsb",
|
|
478
|
+
"dua",
|
|
479
|
+
"dyo",
|
|
480
|
+
"dz",
|
|
481
|
+
"ebu",
|
|
482
|
+
"ee",
|
|
483
|
+
"ee-TG",
|
|
484
|
+
"el",
|
|
485
|
+
"el-CY",
|
|
486
|
+
"en",
|
|
487
|
+
"en-001",
|
|
488
|
+
"en-150",
|
|
489
|
+
"en-AE",
|
|
490
|
+
"en-AG",
|
|
491
|
+
"en-AI",
|
|
492
|
+
"en-AS",
|
|
493
|
+
"en-AT",
|
|
494
|
+
"en-AU",
|
|
495
|
+
"en-BB",
|
|
496
|
+
"en-BE",
|
|
497
|
+
"en-BI",
|
|
498
|
+
"en-BM",
|
|
499
|
+
"en-BS",
|
|
500
|
+
"en-BW",
|
|
501
|
+
"en-BZ",
|
|
502
|
+
"en-CA",
|
|
503
|
+
"en-CC",
|
|
504
|
+
"en-CH",
|
|
505
|
+
"en-CK",
|
|
506
|
+
"en-CM",
|
|
507
|
+
"en-CX",
|
|
508
|
+
"en-CY",
|
|
509
|
+
"en-DE",
|
|
510
|
+
"en-DG",
|
|
511
|
+
"en-DK",
|
|
512
|
+
"en-DM",
|
|
513
|
+
"en-ER",
|
|
514
|
+
"en-FI",
|
|
515
|
+
"en-FJ",
|
|
516
|
+
"en-FK",
|
|
517
|
+
"en-FM",
|
|
518
|
+
"en-GB",
|
|
519
|
+
"en-GD",
|
|
520
|
+
"en-GG",
|
|
521
|
+
"en-GH",
|
|
522
|
+
"en-GI",
|
|
523
|
+
"en-GM",
|
|
524
|
+
"en-GU",
|
|
525
|
+
"en-GY",
|
|
526
|
+
"en-HK",
|
|
527
|
+
"en-IE",
|
|
528
|
+
"en-IL",
|
|
529
|
+
"en-IM",
|
|
530
|
+
"en-IN",
|
|
531
|
+
"en-IO",
|
|
532
|
+
"en-JE",
|
|
533
|
+
"en-JM",
|
|
534
|
+
"en-KE",
|
|
535
|
+
"en-KI",
|
|
536
|
+
"en-KN",
|
|
537
|
+
"en-KY",
|
|
538
|
+
"en-LC",
|
|
539
|
+
"en-LR",
|
|
540
|
+
"en-LS",
|
|
541
|
+
"en-MG",
|
|
542
|
+
"en-MH",
|
|
543
|
+
"en-MO",
|
|
544
|
+
"en-MP",
|
|
545
|
+
"en-MS",
|
|
546
|
+
"en-MT",
|
|
547
|
+
"en-MU",
|
|
548
|
+
"en-MW",
|
|
549
|
+
"en-MY",
|
|
550
|
+
"en-NA",
|
|
551
|
+
"en-NF",
|
|
552
|
+
"en-NG",
|
|
553
|
+
"en-NL",
|
|
554
|
+
"en-NR",
|
|
555
|
+
"en-NU",
|
|
556
|
+
"en-NZ",
|
|
557
|
+
"en-PG",
|
|
558
|
+
"en-PH",
|
|
559
|
+
"en-PK",
|
|
560
|
+
"en-PN",
|
|
561
|
+
"en-PR",
|
|
562
|
+
"en-PW",
|
|
563
|
+
"en-RW",
|
|
564
|
+
"en-SB",
|
|
565
|
+
"en-SC",
|
|
566
|
+
"en-SD",
|
|
567
|
+
"en-SE",
|
|
568
|
+
"en-SG",
|
|
569
|
+
"en-SH",
|
|
570
|
+
"en-SI",
|
|
571
|
+
"en-SL",
|
|
572
|
+
"en-SS",
|
|
573
|
+
"en-SX",
|
|
574
|
+
"en-SZ",
|
|
575
|
+
"en-TC",
|
|
576
|
+
"en-TK",
|
|
577
|
+
"en-TO",
|
|
578
|
+
"en-TT",
|
|
579
|
+
"en-TV",
|
|
580
|
+
"en-TZ",
|
|
581
|
+
"en-UG",
|
|
582
|
+
"en-UM",
|
|
583
|
+
"en-VC",
|
|
584
|
+
"en-VG",
|
|
585
|
+
"en-VI",
|
|
586
|
+
"en-VU",
|
|
587
|
+
"en-WS",
|
|
588
|
+
"en-ZA",
|
|
589
|
+
"en-ZM",
|
|
590
|
+
"en-ZW",
|
|
591
|
+
"eo",
|
|
592
|
+
"es",
|
|
593
|
+
"es-419",
|
|
594
|
+
"es-AR",
|
|
595
|
+
"es-BO",
|
|
596
|
+
"es-BR",
|
|
597
|
+
"es-BZ",
|
|
598
|
+
"es-CL",
|
|
599
|
+
"es-CO",
|
|
600
|
+
"es-CR",
|
|
601
|
+
"es-CU",
|
|
602
|
+
"es-DO",
|
|
603
|
+
"es-EA",
|
|
604
|
+
"es-EC",
|
|
605
|
+
"es-GQ",
|
|
606
|
+
"es-GT",
|
|
607
|
+
"es-HN",
|
|
608
|
+
"es-IC",
|
|
609
|
+
"es-MX",
|
|
610
|
+
"es-NI",
|
|
611
|
+
"es-PA",
|
|
612
|
+
"es-PE",
|
|
613
|
+
"es-PH",
|
|
614
|
+
"es-PR",
|
|
615
|
+
"es-PY",
|
|
616
|
+
"es-SV",
|
|
617
|
+
"es-US",
|
|
618
|
+
"es-UY",
|
|
619
|
+
"es-VE",
|
|
620
|
+
"et",
|
|
621
|
+
"eu",
|
|
622
|
+
"ewo",
|
|
623
|
+
"fa",
|
|
624
|
+
"fa-AF",
|
|
625
|
+
"ff",
|
|
626
|
+
"ff-Adlm",
|
|
627
|
+
"ff-Adlm-BF",
|
|
628
|
+
"ff-Adlm-CM",
|
|
629
|
+
"ff-Adlm-GH",
|
|
630
|
+
"ff-Adlm-GM",
|
|
631
|
+
"ff-Adlm-GW",
|
|
632
|
+
"ff-Adlm-LR",
|
|
633
|
+
"ff-Adlm-MR",
|
|
634
|
+
"ff-Adlm-NE",
|
|
635
|
+
"ff-Adlm-NG",
|
|
636
|
+
"ff-Adlm-SL",
|
|
637
|
+
"ff-Adlm-SN",
|
|
638
|
+
"ff-Latn",
|
|
639
|
+
"ff-Latn-BF",
|
|
640
|
+
"ff-Latn-CM",
|
|
641
|
+
"ff-Latn-GH",
|
|
642
|
+
"ff-Latn-GM",
|
|
643
|
+
"ff-Latn-GN",
|
|
644
|
+
"ff-Latn-GW",
|
|
645
|
+
"ff-Latn-LR",
|
|
646
|
+
"ff-Latn-MR",
|
|
647
|
+
"ff-Latn-NE",
|
|
648
|
+
"ff-Latn-NG",
|
|
649
|
+
"ff-Latn-SL",
|
|
650
|
+
"fi",
|
|
651
|
+
"fil",
|
|
652
|
+
"fo",
|
|
653
|
+
"fo-DK",
|
|
654
|
+
"fr",
|
|
655
|
+
"fr-BE",
|
|
656
|
+
"fr-BF",
|
|
657
|
+
"fr-BI",
|
|
658
|
+
"fr-BJ",
|
|
659
|
+
"fr-BL",
|
|
660
|
+
"fr-CA",
|
|
661
|
+
"fr-CD",
|
|
662
|
+
"fr-CF",
|
|
663
|
+
"fr-CG",
|
|
664
|
+
"fr-CH",
|
|
665
|
+
"fr-CI",
|
|
666
|
+
"fr-CM",
|
|
667
|
+
"fr-DJ",
|
|
668
|
+
"fr-DZ",
|
|
669
|
+
"fr-GA",
|
|
670
|
+
"fr-GF",
|
|
671
|
+
"fr-GN",
|
|
672
|
+
"fr-GP",
|
|
673
|
+
"fr-GQ",
|
|
674
|
+
"fr-HT",
|
|
675
|
+
"fr-KM",
|
|
676
|
+
"fr-LU",
|
|
677
|
+
"fr-MA",
|
|
678
|
+
"fr-MC",
|
|
679
|
+
"fr-MF",
|
|
680
|
+
"fr-MG",
|
|
681
|
+
"fr-ML",
|
|
682
|
+
"fr-MQ",
|
|
683
|
+
"fr-MR",
|
|
684
|
+
"fr-MU",
|
|
685
|
+
"fr-NC",
|
|
686
|
+
"fr-NE",
|
|
687
|
+
"fr-PF",
|
|
688
|
+
"fr-PM",
|
|
689
|
+
"fr-RE",
|
|
690
|
+
"fr-RW",
|
|
691
|
+
"fr-SC",
|
|
692
|
+
"fr-SN",
|
|
693
|
+
"fr-SY",
|
|
694
|
+
"fr-TD",
|
|
695
|
+
"fr-TG",
|
|
696
|
+
"fr-TN",
|
|
697
|
+
"fr-VU",
|
|
698
|
+
"fr-WF",
|
|
699
|
+
"fr-YT",
|
|
700
|
+
"fur",
|
|
701
|
+
"fy",
|
|
702
|
+
"ga",
|
|
703
|
+
"ga-GB",
|
|
704
|
+
"gd",
|
|
705
|
+
"gl",
|
|
706
|
+
"gsw",
|
|
707
|
+
"gsw-FR",
|
|
708
|
+
"gsw-LI",
|
|
709
|
+
"gu",
|
|
710
|
+
"guz",
|
|
711
|
+
"gv",
|
|
712
|
+
"ha",
|
|
713
|
+
"ha-GH",
|
|
714
|
+
"ha-NE",
|
|
715
|
+
"haw",
|
|
716
|
+
"he",
|
|
717
|
+
"hi",
|
|
718
|
+
"hr",
|
|
719
|
+
"hr-BA",
|
|
720
|
+
"hsb",
|
|
721
|
+
"hu",
|
|
722
|
+
"hy",
|
|
723
|
+
"ia",
|
|
724
|
+
"id",
|
|
725
|
+
"ig",
|
|
726
|
+
"ii",
|
|
727
|
+
"is",
|
|
728
|
+
"it",
|
|
729
|
+
"it-CH",
|
|
730
|
+
"it-SM",
|
|
731
|
+
"it-VA",
|
|
732
|
+
"ja",
|
|
733
|
+
"jgo",
|
|
734
|
+
"jmc",
|
|
735
|
+
"jv",
|
|
736
|
+
"ka",
|
|
737
|
+
"kab",
|
|
738
|
+
"kam",
|
|
739
|
+
"kde",
|
|
740
|
+
"kea",
|
|
741
|
+
"kgp",
|
|
742
|
+
"khq",
|
|
743
|
+
"ki",
|
|
744
|
+
"kk",
|
|
745
|
+
"kkj",
|
|
746
|
+
"kl",
|
|
747
|
+
"kln",
|
|
748
|
+
"km",
|
|
749
|
+
"kn",
|
|
750
|
+
"ko",
|
|
751
|
+
"ko-KP",
|
|
752
|
+
"kok",
|
|
753
|
+
"ks",
|
|
754
|
+
"ks-Arab",
|
|
755
|
+
"ksb",
|
|
756
|
+
"ksf",
|
|
757
|
+
"ksh",
|
|
758
|
+
"ku",
|
|
759
|
+
"kw",
|
|
760
|
+
"ky",
|
|
761
|
+
"lag",
|
|
762
|
+
"lb",
|
|
763
|
+
"lg",
|
|
764
|
+
"lkt",
|
|
765
|
+
"ln",
|
|
766
|
+
"ln-AO",
|
|
767
|
+
"ln-CF",
|
|
768
|
+
"ln-CG",
|
|
769
|
+
"lo",
|
|
770
|
+
"lrc",
|
|
771
|
+
"lrc-IQ",
|
|
772
|
+
"lt",
|
|
773
|
+
"lu",
|
|
774
|
+
"luo",
|
|
775
|
+
"luy",
|
|
776
|
+
"lv",
|
|
777
|
+
"mai",
|
|
778
|
+
"mas",
|
|
779
|
+
"mas-TZ",
|
|
780
|
+
"mer",
|
|
781
|
+
"mfe",
|
|
782
|
+
"mg",
|
|
783
|
+
"mgh",
|
|
784
|
+
"mgo",
|
|
785
|
+
"mi",
|
|
786
|
+
"mk",
|
|
787
|
+
"ml",
|
|
788
|
+
"mn",
|
|
789
|
+
"mni",
|
|
790
|
+
"mni-Beng",
|
|
791
|
+
"mr",
|
|
792
|
+
"ms",
|
|
793
|
+
"ms-BN",
|
|
794
|
+
"ms-ID",
|
|
795
|
+
"ms-SG",
|
|
796
|
+
"mt",
|
|
797
|
+
"mua",
|
|
798
|
+
"my",
|
|
799
|
+
"mzn",
|
|
800
|
+
"naq",
|
|
801
|
+
"nb",
|
|
802
|
+
"nb-SJ",
|
|
803
|
+
"nd",
|
|
804
|
+
"nds",
|
|
805
|
+
"nds-NL",
|
|
806
|
+
"ne",
|
|
807
|
+
"ne-IN",
|
|
808
|
+
"nl",
|
|
809
|
+
"nl-AW",
|
|
810
|
+
"nl-BE",
|
|
811
|
+
"nl-BQ",
|
|
812
|
+
"nl-CW",
|
|
813
|
+
"nl-SR",
|
|
814
|
+
"nl-SX",
|
|
815
|
+
"nmg",
|
|
816
|
+
"nn",
|
|
817
|
+
"nnh",
|
|
818
|
+
"no",
|
|
819
|
+
"nus",
|
|
820
|
+
"nyn",
|
|
821
|
+
"om",
|
|
822
|
+
"om-KE",
|
|
823
|
+
"or",
|
|
824
|
+
"os",
|
|
825
|
+
"os-RU",
|
|
826
|
+
"pa",
|
|
827
|
+
"pa-Arab",
|
|
828
|
+
"pa-Guru",
|
|
829
|
+
"pcm",
|
|
830
|
+
"pl",
|
|
831
|
+
"ps",
|
|
832
|
+
"ps-PK",
|
|
833
|
+
"pt",
|
|
834
|
+
"pt-AO",
|
|
835
|
+
"pt-CH",
|
|
836
|
+
"pt-CV",
|
|
837
|
+
"pt-GQ",
|
|
838
|
+
"pt-GW",
|
|
839
|
+
"pt-LU",
|
|
840
|
+
"pt-MO",
|
|
841
|
+
"pt-MZ",
|
|
842
|
+
"pt-PT",
|
|
843
|
+
"pt-ST",
|
|
844
|
+
"pt-TL",
|
|
845
|
+
"qu",
|
|
846
|
+
"qu-BO",
|
|
847
|
+
"qu-EC",
|
|
848
|
+
"rm",
|
|
849
|
+
"rn",
|
|
850
|
+
"ro",
|
|
851
|
+
"ro-MD",
|
|
852
|
+
"rof",
|
|
853
|
+
"ru",
|
|
854
|
+
"ru-BY",
|
|
855
|
+
"ru-KG",
|
|
856
|
+
"ru-KZ",
|
|
857
|
+
"ru-MD",
|
|
858
|
+
"ru-UA",
|
|
859
|
+
"rw",
|
|
860
|
+
"rwk",
|
|
861
|
+
"sa",
|
|
862
|
+
"sah",
|
|
863
|
+
"saq",
|
|
864
|
+
"sat",
|
|
865
|
+
"sat-Olck",
|
|
866
|
+
"sbp",
|
|
867
|
+
"sc",
|
|
868
|
+
"sd",
|
|
869
|
+
"sd-Arab",
|
|
870
|
+
"sd-Deva",
|
|
871
|
+
"se",
|
|
872
|
+
"se-FI",
|
|
873
|
+
"se-SE",
|
|
874
|
+
"seh",
|
|
875
|
+
"ses",
|
|
876
|
+
"sg",
|
|
877
|
+
"shi",
|
|
878
|
+
"shi-Latn",
|
|
879
|
+
"shi-Tfng",
|
|
880
|
+
"si",
|
|
881
|
+
"sk",
|
|
882
|
+
"sl",
|
|
883
|
+
"smn",
|
|
884
|
+
"sn",
|
|
885
|
+
"so",
|
|
886
|
+
"so-DJ",
|
|
887
|
+
"so-ET",
|
|
888
|
+
"so-KE",
|
|
889
|
+
"sq",
|
|
890
|
+
"sq-MK",
|
|
891
|
+
"sq-XK",
|
|
892
|
+
"sr",
|
|
893
|
+
"sr-Cyrl",
|
|
894
|
+
"sr-Cyrl-BA",
|
|
895
|
+
"sr-Cyrl-ME",
|
|
896
|
+
"sr-Cyrl-XK",
|
|
897
|
+
"sr-Latn",
|
|
898
|
+
"sr-Latn-BA",
|
|
899
|
+
"sr-Latn-ME",
|
|
900
|
+
"sr-Latn-XK",
|
|
901
|
+
"su",
|
|
902
|
+
"su-Latn",
|
|
903
|
+
"sv",
|
|
904
|
+
"sv-AX",
|
|
905
|
+
"sv-FI",
|
|
906
|
+
"sw",
|
|
907
|
+
"sw-CD",
|
|
908
|
+
"sw-KE",
|
|
909
|
+
"sw-UG",
|
|
910
|
+
"ta",
|
|
911
|
+
"ta-LK",
|
|
912
|
+
"ta-MY",
|
|
913
|
+
"ta-SG",
|
|
914
|
+
"te",
|
|
915
|
+
"teo",
|
|
916
|
+
"teo-KE",
|
|
917
|
+
"tg",
|
|
918
|
+
"th",
|
|
919
|
+
"ti",
|
|
920
|
+
"ti-ER",
|
|
921
|
+
"tk",
|
|
922
|
+
"to",
|
|
923
|
+
"tr",
|
|
924
|
+
"tr-CY",
|
|
925
|
+
"tt",
|
|
926
|
+
"twq",
|
|
927
|
+
"tzm",
|
|
928
|
+
"ug",
|
|
929
|
+
"uk",
|
|
930
|
+
"und",
|
|
931
|
+
"ur",
|
|
932
|
+
"ur-IN",
|
|
933
|
+
"uz",
|
|
934
|
+
"uz-Arab",
|
|
935
|
+
"uz-Cyrl",
|
|
936
|
+
"uz-Latn",
|
|
937
|
+
"vai",
|
|
938
|
+
"vai-Latn",
|
|
939
|
+
"vai-Vaii",
|
|
940
|
+
"vi",
|
|
941
|
+
"vun",
|
|
942
|
+
"wae",
|
|
943
|
+
"wo",
|
|
944
|
+
"xh",
|
|
945
|
+
"xog",
|
|
946
|
+
"yav",
|
|
947
|
+
"yi",
|
|
948
|
+
"yo",
|
|
949
|
+
"yo-BJ",
|
|
950
|
+
"yrl",
|
|
951
|
+
"yrl-CO",
|
|
952
|
+
"yrl-VE",
|
|
953
|
+
"yue",
|
|
954
|
+
"yue-Hans",
|
|
955
|
+
"yue-Hant",
|
|
956
|
+
"zgh",
|
|
957
|
+
"zh",
|
|
958
|
+
"zh-Hans",
|
|
959
|
+
"zh-Hans-HK",
|
|
960
|
+
"zh-Hans-MO",
|
|
961
|
+
"zh-Hans-SG",
|
|
962
|
+
"zh-Hant",
|
|
963
|
+
"zh-Hant-HK",
|
|
964
|
+
"zh-Hant-MO",
|
|
965
|
+
"zu"
|
|
966
|
+
];
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region packages/intl-displaynames/should-polyfill.ts
|
|
969
|
+
/**
|
|
970
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
|
|
971
|
+
*/
|
|
972
|
+
function hasMissingICUBug() {
|
|
973
|
+
const DisplayNames = Intl.DisplayNames;
|
|
974
|
+
if (DisplayNames && !DisplayNames.polyfilled) return new DisplayNames(["en"], { type: "region" }).of("CA") === "CA";
|
|
975
|
+
return false;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* https://bugs.chromium.org/p/chromium/issues/detail?id=1176979
|
|
979
|
+
* https://github.com/formatjs/formatjs/issues/5889
|
|
980
|
+
*
|
|
981
|
+
* Tests if the implementation properly canonicalizes script codes per ECMA-402 spec.
|
|
982
|
+
* The spec requires CanonicalCodeForDisplayNames to convert lowercase 'arab' to title-case 'Arab'
|
|
983
|
+
* before lookup. This test uses lowercase input to verify canonicalization happens.
|
|
984
|
+
*
|
|
985
|
+
* - Correct implementations: canonicalize 'arab' → 'Arab', look up → return 'Arabic'
|
|
986
|
+
* - Buggy implementations (old Node.js): don't canonicalize, look up 'arab' literally → return 'arab'
|
|
987
|
+
*
|
|
988
|
+
* See ECMA-402 section 12.5.1: CanonicalCodeForDisplayNames
|
|
989
|
+
*/
|
|
990
|
+
function hasScriptBug() {
|
|
991
|
+
const DisplayNames = Intl.DisplayNames;
|
|
992
|
+
if (DisplayNames && !DisplayNames.polyfilled) return new DisplayNames(["en"], { type: "script" }).of("arab") !== "Arabic";
|
|
993
|
+
return false;
|
|
994
|
+
}
|
|
995
|
+
function supportedLocalesOf(locale) {
|
|
996
|
+
if (!locale) return true;
|
|
997
|
+
const locales = Array.isArray(locale) ? locale : [locale];
|
|
998
|
+
return Intl.DisplayNames.supportedLocalesOf(locales).length === locales.length;
|
|
999
|
+
}
|
|
1000
|
+
function _shouldPolyfillWithoutLocale() {
|
|
1001
|
+
return !Intl.DisplayNames || hasMissingICUBug() || hasScriptBug();
|
|
1002
|
+
}
|
|
1003
|
+
function shouldPolyfill(locale = "en") {
|
|
1004
|
+
try {
|
|
1005
|
+
if (_shouldPolyfillWithoutLocale() || !supportedLocalesOf(locale)) return match([locale], supportedLocales, "en");
|
|
1006
|
+
} catch {
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region packages/intl-displaynames/polyfill.ts
|
|
3
1012
|
if (shouldPolyfill()) {
|
|
4
1013
|
Object.defineProperty(Intl, "DisplayNames", {
|
|
5
1014
|
value: DisplayNames,
|
|
@@ -7,10 +1016,12 @@ if (shouldPolyfill()) {
|
|
|
7
1016
|
writable: true,
|
|
8
1017
|
configurable: true
|
|
9
1018
|
});
|
|
10
|
-
// Drain any locale data that was buffered before polyfill loaded
|
|
11
1019
|
const buf = globalThis.__FORMATJS_DISPLAYNAMES_DATA__;
|
|
12
1020
|
if (buf) {
|
|
13
1021
|
for (const d of buf) DisplayNames.__addLocaleData(d);
|
|
14
1022
|
delete globalThis.__FORMATJS_DISPLAYNAMES_DATA__;
|
|
15
1023
|
}
|
|
16
1024
|
}
|
|
1025
|
+
//#endregion
|
|
1026
|
+
|
|
1027
|
+
//# sourceMappingURL=polyfill.js.map
|