@formatjs/intl-locale 2.4.38 → 2.4.42
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.js +64 -64
- package/lib/index.js +3 -3
- package/package.json +3 -3
- package/polyfill.iife.js +54 -57
- package/polyfill.js +1 -1
package/index.js
CHANGED
|
@@ -4,25 +4,25 @@ exports.Locale = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
6
6
|
var intl_getcanonicallocales_1 = require("@formatjs/intl-getcanonicallocales");
|
|
7
|
-
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
7
|
+
var get_internal_slots_1 = (0, tslib_1.__importDefault)(require("./get_internal_slots"));
|
|
8
8
|
var RELEVANT_EXTENSION_KEYS = ['ca', 'co', 'hc', 'kf', 'kn', 'nu'];
|
|
9
9
|
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
10
10
|
function applyOptionsToTag(tag, options) {
|
|
11
|
-
ecma402_abstract_1.invariant(typeof tag === 'string', 'language tag must be a string');
|
|
12
|
-
ecma402_abstract_1.invariant(intl_getcanonicallocales_1.isStructurallyValidLanguageTag(tag), 'malformed language tag', RangeError);
|
|
13
|
-
var language = ecma402_abstract_1.GetOption(options, 'language', 'string', undefined, undefined);
|
|
11
|
+
(0, ecma402_abstract_1.invariant)(typeof tag === 'string', 'language tag must be a string');
|
|
12
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isStructurallyValidLanguageTag)(tag), 'malformed language tag', RangeError);
|
|
13
|
+
var language = (0, ecma402_abstract_1.GetOption)(options, 'language', 'string', undefined, undefined);
|
|
14
14
|
if (language !== undefined) {
|
|
15
|
-
ecma402_abstract_1.invariant(intl_getcanonicallocales_1.isUnicodeLanguageSubtag(language), 'Malformed unicode_language_subtag', RangeError);
|
|
15
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeLanguageSubtag)(language), 'Malformed unicode_language_subtag', RangeError);
|
|
16
16
|
}
|
|
17
|
-
var script = ecma402_abstract_1.GetOption(options, 'script', 'string', undefined, undefined);
|
|
17
|
+
var script = (0, ecma402_abstract_1.GetOption)(options, 'script', 'string', undefined, undefined);
|
|
18
18
|
if (script !== undefined) {
|
|
19
|
-
ecma402_abstract_1.invariant(intl_getcanonicallocales_1.isUnicodeScriptSubtag(script), 'Malformed unicode_script_subtag', RangeError);
|
|
19
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeScriptSubtag)(script), 'Malformed unicode_script_subtag', RangeError);
|
|
20
20
|
}
|
|
21
|
-
var region = ecma402_abstract_1.GetOption(options, 'region', 'string', undefined, undefined);
|
|
21
|
+
var region = (0, ecma402_abstract_1.GetOption)(options, 'region', 'string', undefined, undefined);
|
|
22
22
|
if (region !== undefined) {
|
|
23
|
-
ecma402_abstract_1.invariant(intl_getcanonicallocales_1.isUnicodeRegionSubtag(region), 'Malformed unicode_region_subtag', RangeError);
|
|
23
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeRegionSubtag)(region), 'Malformed unicode_region_subtag', RangeError);
|
|
24
24
|
}
|
|
25
|
-
var languageId = intl_getcanonicallocales_1.parseUnicodeLanguageId(tag);
|
|
25
|
+
var languageId = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(tag);
|
|
26
26
|
if (language !== undefined) {
|
|
27
27
|
languageId.lang = language;
|
|
28
28
|
}
|
|
@@ -32,12 +32,12 @@ function applyOptionsToTag(tag, options) {
|
|
|
32
32
|
if (region !== undefined) {
|
|
33
33
|
languageId.region = region;
|
|
34
34
|
}
|
|
35
|
-
return Intl.getCanonicalLocales(intl_getcanonicallocales_1.emitUnicodeLocaleId(tslib_1.__assign(tslib_1.__assign({}, intl_getcanonicallocales_1.parseUnicodeLocaleId(tag)), { lang: languageId })))[0];
|
|
35
|
+
return Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag)), { lang: languageId })))[0];
|
|
36
36
|
}
|
|
37
37
|
function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
38
38
|
var unicodeExtension;
|
|
39
39
|
var keywords = [];
|
|
40
|
-
var ast = intl_getcanonicallocales_1.parseUnicodeLocaleId(tag);
|
|
40
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
41
41
|
for (var _i = 0, _a = ast.extensions; _i < _a.length; _i++) {
|
|
42
42
|
var ext = _a[_i];
|
|
43
43
|
if (ext.type === 'u') {
|
|
@@ -57,10 +57,10 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
57
57
|
value = entry[1];
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
ecma402_abstract_1.invariant(key in options, key
|
|
60
|
+
(0, ecma402_abstract_1.invariant)(key in options, "".concat(key, " must be in options"));
|
|
61
61
|
var optionsValue = options[key];
|
|
62
62
|
if (optionsValue !== undefined) {
|
|
63
|
-
ecma402_abstract_1.invariant(typeof optionsValue === 'string', "Value for "
|
|
63
|
+
(0, ecma402_abstract_1.invariant)(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
|
|
64
64
|
value = optionsValue;
|
|
65
65
|
if (entry) {
|
|
66
66
|
entry[1] = value;
|
|
@@ -83,7 +83,7 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
83
83
|
else {
|
|
84
84
|
unicodeExtension.keywords = keywords;
|
|
85
85
|
}
|
|
86
|
-
result.locale = Intl.getCanonicalLocales(intl_getcanonicallocales_1.emitUnicodeLocaleId(ast))[0];
|
|
86
|
+
result.locale = Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast))[0];
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
@@ -100,45 +100,45 @@ function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
|
100
100
|
lang: !lang || lang === 'und' ? replacement.lang : lang,
|
|
101
101
|
script: script || replacement.script,
|
|
102
102
|
region: region || replacement.region,
|
|
103
|
-
variants: tslib_1.__spreadArray(tslib_1.__spreadArray([], variants), replacement.variants),
|
|
103
|
+
variants: (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], variants, true), replacement.variants, true),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
function addLikelySubtags(tag) {
|
|
107
|
-
var ast = intl_getcanonicallocales_1.parseUnicodeLocaleId(tag);
|
|
107
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
108
108
|
var unicodeLangId = ast.lang;
|
|
109
109
|
var lang = unicodeLangId.lang, script = unicodeLangId.script, region = unicodeLangId.region, variants = unicodeLangId.variants;
|
|
110
110
|
if (script && region) {
|
|
111
|
-
var match_1 = intl_getcanonicallocales_1.likelySubtags[intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, script: script, region: region, variants: [] })];
|
|
111
|
+
var match_1 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, region: region, variants: [] })];
|
|
112
112
|
if (match_1) {
|
|
113
|
-
var parts_1 = intl_getcanonicallocales_1.parseUnicodeLanguageId(match_1);
|
|
113
|
+
var parts_1 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_1);
|
|
114
114
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, undefined, variants, parts_1);
|
|
115
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(ast);
|
|
115
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
if (script) {
|
|
119
|
-
var match_2 = intl_getcanonicallocales_1.likelySubtags[intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, script: script, variants: [] })];
|
|
119
|
+
var match_2 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] })];
|
|
120
120
|
if (match_2) {
|
|
121
|
-
var parts_2 = intl_getcanonicallocales_1.parseUnicodeLanguageId(match_2);
|
|
121
|
+
var parts_2 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_2);
|
|
122
122
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, region, variants, parts_2);
|
|
123
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(ast);
|
|
123
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
if (region) {
|
|
127
|
-
var match_3 = intl_getcanonicallocales_1.likelySubtags[intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, region: region, variants: [] })];
|
|
127
|
+
var match_3 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] })];
|
|
128
128
|
if (match_3) {
|
|
129
|
-
var parts_3 = intl_getcanonicallocales_1.parseUnicodeLanguageId(match_3);
|
|
129
|
+
var parts_3 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_3);
|
|
130
130
|
ast.lang = mergeUnicodeLanguageId(undefined, script, undefined, variants, parts_3);
|
|
131
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(ast);
|
|
131
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
var match = intl_getcanonicallocales_1.likelySubtags[lang] ||
|
|
135
|
-
intl_getcanonicallocales_1.likelySubtags[intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: 'und', script: script, variants: [] })];
|
|
135
|
+
intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: 'und', script: script, variants: [] })];
|
|
136
136
|
if (!match) {
|
|
137
137
|
throw new Error("No match for addLikelySubtags");
|
|
138
138
|
}
|
|
139
|
-
var parts = intl_getcanonicallocales_1.parseUnicodeLanguageId(match);
|
|
139
|
+
var parts = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match);
|
|
140
140
|
ast.lang = mergeUnicodeLanguageId(undefined, script, region, variants, parts);
|
|
141
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(ast);
|
|
141
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
|
|
@@ -149,23 +149,23 @@ function removeLikelySubtags(tag) {
|
|
|
149
149
|
if (!maxLocale) {
|
|
150
150
|
return tag;
|
|
151
151
|
}
|
|
152
|
-
maxLocale = intl_getcanonicallocales_1.emitUnicodeLanguageId(tslib_1.__assign(tslib_1.__assign({}, intl_getcanonicallocales_1.parseUnicodeLanguageId(maxLocale)), { variants: [] }));
|
|
153
|
-
var ast = intl_getcanonicallocales_1.parseUnicodeLocaleId(tag);
|
|
152
|
+
maxLocale = (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(maxLocale)), { variants: [] }));
|
|
153
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
154
154
|
var _a = ast.lang, lang = _a.lang, script = _a.script, region = _a.region, variants = _a.variants;
|
|
155
|
-
var trial = addLikelySubtags(intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, variants: [] }));
|
|
155
|
+
var trial = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, variants: [] }));
|
|
156
156
|
if (trial === maxLocale) {
|
|
157
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
|
|
157
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
|
|
158
158
|
}
|
|
159
159
|
if (region) {
|
|
160
|
-
var trial_1 = addLikelySubtags(intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, region: region, variants: [] }));
|
|
160
|
+
var trial_1 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] }));
|
|
161
161
|
if (trial_1 === maxLocale) {
|
|
162
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
|
|
162
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
if (script) {
|
|
166
|
-
var trial_2 = addLikelySubtags(intl_getcanonicallocales_1.emitUnicodeLanguageId({ lang: lang, script: script, variants: [] }));
|
|
166
|
+
var trial_2 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] }));
|
|
167
167
|
if (trial_2 === maxLocale) {
|
|
168
|
-
return intl_getcanonicallocales_1.emitUnicodeLocaleId(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
|
|
168
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
return tag;
|
|
@@ -201,42 +201,42 @@ var Locale = /** @class */ (function () {
|
|
|
201
201
|
}
|
|
202
202
|
var internalSlots;
|
|
203
203
|
if (typeof tag === 'object' &&
|
|
204
|
-
(internalSlots = get_internal_slots_1.default(tag)) &&
|
|
204
|
+
(internalSlots = (0, get_internal_slots_1.default)(tag)) &&
|
|
205
205
|
internalSlots.initializedLocale) {
|
|
206
206
|
tag = internalSlots.locale;
|
|
207
207
|
}
|
|
208
208
|
else {
|
|
209
209
|
tag = tag.toString();
|
|
210
210
|
}
|
|
211
|
-
internalSlots = get_internal_slots_1.default(this);
|
|
212
|
-
var options = ecma402_abstract_1.CoerceOptionsToObject(opts);
|
|
211
|
+
internalSlots = (0, get_internal_slots_1.default)(this);
|
|
212
|
+
var options = (0, ecma402_abstract_1.CoerceOptionsToObject)(opts);
|
|
213
213
|
tag = applyOptionsToTag(tag, options);
|
|
214
214
|
var opt = Object.create(null);
|
|
215
|
-
var calendar = ecma402_abstract_1.GetOption(options, 'calendar', 'string', undefined, undefined);
|
|
215
|
+
var calendar = (0, ecma402_abstract_1.GetOption)(options, 'calendar', 'string', undefined, undefined);
|
|
216
216
|
if (calendar !== undefined) {
|
|
217
217
|
if (!UNICODE_TYPE_REGEX.test(calendar)) {
|
|
218
218
|
throw new RangeError('invalid calendar');
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
opt.ca = calendar;
|
|
222
|
-
var collation = ecma402_abstract_1.GetOption(options, 'collation', 'string', undefined, undefined);
|
|
222
|
+
var collation = (0, ecma402_abstract_1.GetOption)(options, 'collation', 'string', undefined, undefined);
|
|
223
223
|
if (collation !== undefined) {
|
|
224
224
|
if (!UNICODE_TYPE_REGEX.test(collation)) {
|
|
225
225
|
throw new RangeError('invalid collation');
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
opt.co = collation;
|
|
229
|
-
var hc = ecma402_abstract_1.GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
229
|
+
var hc = (0, ecma402_abstract_1.GetOption)(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
230
230
|
opt.hc = hc;
|
|
231
|
-
var kf = ecma402_abstract_1.GetOption(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
231
|
+
var kf = (0, ecma402_abstract_1.GetOption)(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
232
232
|
opt.kf = kf;
|
|
233
|
-
var _kn = ecma402_abstract_1.GetOption(options, 'numeric', 'boolean', undefined, undefined);
|
|
233
|
+
var _kn = (0, ecma402_abstract_1.GetOption)(options, 'numeric', 'boolean', undefined, undefined);
|
|
234
234
|
var kn;
|
|
235
235
|
if (_kn !== undefined) {
|
|
236
236
|
kn = String(_kn);
|
|
237
237
|
}
|
|
238
238
|
opt.kn = kn;
|
|
239
|
-
var numberingSystem = ecma402_abstract_1.GetOption(options, 'numberingSystem', 'string', undefined, undefined);
|
|
239
|
+
var numberingSystem = (0, ecma402_abstract_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
|
|
240
240
|
if (numberingSystem !== undefined) {
|
|
241
241
|
if (!UNICODE_TYPE_REGEX.test(numberingSystem)) {
|
|
242
242
|
throw new RangeError('Invalid numberingSystem');
|
|
@@ -252,7 +252,7 @@ var Locale = /** @class */ (function () {
|
|
|
252
252
|
internalSlots.caseFirst = r.kf;
|
|
253
253
|
}
|
|
254
254
|
if (relevantExtensionKeys.indexOf('kn') > -1) {
|
|
255
|
-
internalSlots.numeric = ecma402_abstract_1.SameValue(r.kn, 'true');
|
|
255
|
+
internalSlots.numeric = (0, ecma402_abstract_1.SameValue)(r.kn, 'true');
|
|
256
256
|
}
|
|
257
257
|
internalSlots.numberingSystem = r.nu;
|
|
258
258
|
}
|
|
@@ -260,7 +260,7 @@ var Locale = /** @class */ (function () {
|
|
|
260
260
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
261
261
|
*/
|
|
262
262
|
Locale.prototype.maximize = function () {
|
|
263
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
263
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
264
264
|
try {
|
|
265
265
|
var maximizedLocale = addLikelySubtags(locale);
|
|
266
266
|
return new Locale(maximizedLocale);
|
|
@@ -273,7 +273,7 @@ var Locale = /** @class */ (function () {
|
|
|
273
273
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
274
274
|
*/
|
|
275
275
|
Locale.prototype.minimize = function () {
|
|
276
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
276
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
277
277
|
try {
|
|
278
278
|
var minimizedLocale = removeLikelySubtags(locale);
|
|
279
279
|
return new Locale(minimizedLocale);
|
|
@@ -283,54 +283,54 @@ var Locale = /** @class */ (function () {
|
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
285
|
Locale.prototype.toString = function () {
|
|
286
|
-
return get_internal_slots_1.default(this).locale;
|
|
286
|
+
return (0, get_internal_slots_1.default)(this).locale;
|
|
287
287
|
};
|
|
288
288
|
Object.defineProperty(Locale.prototype, "baseName", {
|
|
289
289
|
get: function () {
|
|
290
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
291
|
-
return intl_getcanonicallocales_1.emitUnicodeLanguageId(intl_getcanonicallocales_1.parseUnicodeLanguageId(locale));
|
|
290
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
291
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)((0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale));
|
|
292
292
|
},
|
|
293
293
|
enumerable: false,
|
|
294
294
|
configurable: true
|
|
295
295
|
});
|
|
296
296
|
Object.defineProperty(Locale.prototype, "calendar", {
|
|
297
297
|
get: function () {
|
|
298
|
-
return get_internal_slots_1.default(this).calendar;
|
|
298
|
+
return (0, get_internal_slots_1.default)(this).calendar;
|
|
299
299
|
},
|
|
300
300
|
enumerable: false,
|
|
301
301
|
configurable: true
|
|
302
302
|
});
|
|
303
303
|
Object.defineProperty(Locale.prototype, "collation", {
|
|
304
304
|
get: function () {
|
|
305
|
-
return get_internal_slots_1.default(this).collation;
|
|
305
|
+
return (0, get_internal_slots_1.default)(this).collation;
|
|
306
306
|
},
|
|
307
307
|
enumerable: false,
|
|
308
308
|
configurable: true
|
|
309
309
|
});
|
|
310
310
|
Object.defineProperty(Locale.prototype, "hourCycle", {
|
|
311
311
|
get: function () {
|
|
312
|
-
return get_internal_slots_1.default(this).hourCycle;
|
|
312
|
+
return (0, get_internal_slots_1.default)(this).hourCycle;
|
|
313
313
|
},
|
|
314
314
|
enumerable: false,
|
|
315
315
|
configurable: true
|
|
316
316
|
});
|
|
317
317
|
Object.defineProperty(Locale.prototype, "caseFirst", {
|
|
318
318
|
get: function () {
|
|
319
|
-
return get_internal_slots_1.default(this).caseFirst;
|
|
319
|
+
return (0, get_internal_slots_1.default)(this).caseFirst;
|
|
320
320
|
},
|
|
321
321
|
enumerable: false,
|
|
322
322
|
configurable: true
|
|
323
323
|
});
|
|
324
324
|
Object.defineProperty(Locale.prototype, "numeric", {
|
|
325
325
|
get: function () {
|
|
326
|
-
return get_internal_slots_1.default(this).numeric;
|
|
326
|
+
return (0, get_internal_slots_1.default)(this).numeric;
|
|
327
327
|
},
|
|
328
328
|
enumerable: false,
|
|
329
329
|
configurable: true
|
|
330
330
|
});
|
|
331
331
|
Object.defineProperty(Locale.prototype, "numberingSystem", {
|
|
332
332
|
get: function () {
|
|
333
|
-
return get_internal_slots_1.default(this).numberingSystem;
|
|
333
|
+
return (0, get_internal_slots_1.default)(this).numberingSystem;
|
|
334
334
|
},
|
|
335
335
|
enumerable: false,
|
|
336
336
|
configurable: true
|
|
@@ -340,8 +340,8 @@ var Locale = /** @class */ (function () {
|
|
|
340
340
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.language
|
|
341
341
|
*/
|
|
342
342
|
get: function () {
|
|
343
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
344
|
-
return intl_getcanonicallocales_1.parseUnicodeLanguageId(locale).lang;
|
|
343
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
344
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).lang;
|
|
345
345
|
},
|
|
346
346
|
enumerable: false,
|
|
347
347
|
configurable: true
|
|
@@ -351,8 +351,8 @@ var Locale = /** @class */ (function () {
|
|
|
351
351
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.script
|
|
352
352
|
*/
|
|
353
353
|
get: function () {
|
|
354
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
355
|
-
return intl_getcanonicallocales_1.parseUnicodeLanguageId(locale).script;
|
|
354
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
355
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).script;
|
|
356
356
|
},
|
|
357
357
|
enumerable: false,
|
|
358
358
|
configurable: true
|
|
@@ -362,8 +362,8 @@ var Locale = /** @class */ (function () {
|
|
|
362
362
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
|
|
363
363
|
*/
|
|
364
364
|
get: function () {
|
|
365
|
-
var locale = get_internal_slots_1.default(this).locale;
|
|
366
|
-
return intl_getcanonicallocales_1.parseUnicodeLanguageId(locale).region;
|
|
365
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
366
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).region;
|
|
367
367
|
},
|
|
368
368
|
enumerable: false,
|
|
369
369
|
configurable: true
|
package/lib/index.js
CHANGED
|
@@ -54,10 +54,10 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
54
54
|
value = entry[1];
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
invariant(key in options, key
|
|
57
|
+
invariant(key in options, "".concat(key, " must be in options"));
|
|
58
58
|
var optionsValue = options[key];
|
|
59
59
|
if (optionsValue !== undefined) {
|
|
60
|
-
invariant(typeof optionsValue === 'string', "Value for "
|
|
60
|
+
invariant(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
|
|
61
61
|
value = optionsValue;
|
|
62
62
|
if (entry) {
|
|
63
63
|
entry[1] = value;
|
|
@@ -97,7 +97,7 @@ function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
|
97
97
|
lang: !lang || lang === 'und' ? replacement.lang : lang,
|
|
98
98
|
script: script || replacement.script,
|
|
99
99
|
region: region || replacement.region,
|
|
100
|
-
variants: __spreadArray(__spreadArray([], variants), replacement.variants),
|
|
100
|
+
variants: __spreadArray(__spreadArray([], variants, true), replacement.variants, true),
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
function addLikelySubtags(tag) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-locale",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.42",
|
|
4
4
|
"description": "Intl.Locale polyfill",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/formatjs/formatjs/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@formatjs/ecma402-abstract": "1.
|
|
28
|
-
"@formatjs/intl-getcanonicallocales": "1.
|
|
27
|
+
"@formatjs/ecma402-abstract": "1.11.1",
|
|
28
|
+
"@formatjs/intl-getcanonicallocales": "1.8.0",
|
|
29
29
|
"tslib": "^2.1.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/polyfill.iife.js
CHANGED
|
@@ -8,11 +8,8 @@
|
|
|
8
8
|
var __markAsModule = function(target) {
|
|
9
9
|
return __defProp(target, "__esModule", { value: true });
|
|
10
10
|
};
|
|
11
|
-
var __require = typeof require !== "undefined" ? require : function(x) {
|
|
12
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
};
|
|
14
11
|
var __commonJS = function(cb, mod) {
|
|
15
|
-
return function
|
|
12
|
+
return function __require() {
|
|
16
13
|
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
14
|
};
|
|
18
15
|
};
|
|
@@ -520,7 +517,7 @@
|
|
|
520
517
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
521
518
|
var locale = requestedLocales_1[_i];
|
|
522
519
|
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
523
|
-
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
520
|
+
var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
|
|
524
521
|
if (availableLocale) {
|
|
525
522
|
result.locale = availableLocale;
|
|
526
523
|
if (locale !== noExtensionLocale) {
|
|
@@ -545,10 +542,10 @@
|
|
|
545
542
|
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
546
543
|
var utils_1 = require_utils();
|
|
547
544
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
548
|
-
var minimizedAvailableLocaleMap =
|
|
549
|
-
|
|
550
|
-
return
|
|
551
|
-
}
|
|
545
|
+
var minimizedAvailableLocaleMap = {};
|
|
546
|
+
availableLocales.forEach(function(l2) {
|
|
547
|
+
return minimizedAvailableLocaleMap[l2] = l2;
|
|
548
|
+
});
|
|
552
549
|
var minimizedAvailableLocales = new Set();
|
|
553
550
|
availableLocales.forEach(function(locale2) {
|
|
554
551
|
var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
|
@@ -577,7 +574,7 @@
|
|
|
577
574
|
foundLocale = minimizedRequestedLocale;
|
|
578
575
|
break;
|
|
579
576
|
}
|
|
580
|
-
foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
577
|
+
foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
581
578
|
}
|
|
582
579
|
return {
|
|
583
580
|
locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
|
|
@@ -595,9 +592,9 @@
|
|
|
595
592
|
exports.UnicodeExtensionValue = void 0;
|
|
596
593
|
var utils_1 = require_utils();
|
|
597
594
|
function UnicodeExtensionValue(extension, key) {
|
|
598
|
-
utils_1.invariant(key.length === 2, "key must have 2 elements");
|
|
595
|
+
(0, utils_1.invariant)(key.length === 2, "key must have 2 elements");
|
|
599
596
|
var size = extension.length;
|
|
600
|
-
var searchValue = "-"
|
|
597
|
+
var searchValue = "-".concat(key, "-");
|
|
601
598
|
var pos = extension.indexOf(searchValue);
|
|
602
599
|
if (pos !== -1) {
|
|
603
600
|
var start = pos + 4;
|
|
@@ -624,7 +621,7 @@
|
|
|
624
621
|
}
|
|
625
622
|
return extension.slice(start, end);
|
|
626
623
|
}
|
|
627
|
-
searchValue = "-"
|
|
624
|
+
searchValue = "-".concat(key);
|
|
628
625
|
pos = extension.indexOf(searchValue);
|
|
629
626
|
if (pos !== -1 && pos + 3 === size) {
|
|
630
627
|
return "";
|
|
@@ -649,40 +646,40 @@
|
|
|
649
646
|
var matcher = options.localeMatcher;
|
|
650
647
|
var r;
|
|
651
648
|
if (matcher === "lookup") {
|
|
652
|
-
r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
649
|
+
r = (0, LookupMatcher_1.LookupMatcher)(availableLocales, requestedLocales, getDefaultLocale);
|
|
653
650
|
} else {
|
|
654
|
-
r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
651
|
+
r = (0, BestFitMatcher_1.BestFitMatcher)(availableLocales, requestedLocales, getDefaultLocale);
|
|
655
652
|
}
|
|
656
653
|
var foundLocale = r.locale;
|
|
657
654
|
var result = { locale: "", dataLocale: foundLocale };
|
|
658
655
|
var supportedExtension = "-u";
|
|
659
656
|
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
660
657
|
var key = relevantExtensionKeys_1[_i];
|
|
661
|
-
utils_1.invariant(foundLocale in localeData, "Missing locale data for "
|
|
658
|
+
(0, utils_1.invariant)(foundLocale in localeData, "Missing locale data for ".concat(foundLocale));
|
|
662
659
|
var foundLocaleData = localeData[foundLocale];
|
|
663
|
-
utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data "
|
|
660
|
+
(0, utils_1.invariant)(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data ".concat(key, " must be an object"));
|
|
664
661
|
var keyLocaleData = foundLocaleData[key];
|
|
665
|
-
utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for "
|
|
662
|
+
(0, utils_1.invariant)(Array.isArray(keyLocaleData), "keyLocaleData for ".concat(key, " must be an array"));
|
|
666
663
|
var value = keyLocaleData[0];
|
|
667
|
-
utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got "
|
|
664
|
+
(0, utils_1.invariant)(typeof value === "string" || value === null, "value must be string or null but got ".concat(typeof value, " in key ").concat(key));
|
|
668
665
|
var supportedExtensionAddition = "";
|
|
669
666
|
if (r.extension) {
|
|
670
|
-
var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
|
|
667
|
+
var requestedValue = (0, UnicodeExtensionValue_1.UnicodeExtensionValue)(r.extension, key);
|
|
671
668
|
if (requestedValue !== void 0) {
|
|
672
669
|
if (requestedValue !== "") {
|
|
673
670
|
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
674
671
|
value = requestedValue;
|
|
675
|
-
supportedExtensionAddition = "-"
|
|
672
|
+
supportedExtensionAddition = "-".concat(key, "-").concat(value);
|
|
676
673
|
}
|
|
677
674
|
} else if (~requestedValue.indexOf("true")) {
|
|
678
675
|
value = "true";
|
|
679
|
-
supportedExtensionAddition = "-"
|
|
676
|
+
supportedExtensionAddition = "-".concat(key);
|
|
680
677
|
}
|
|
681
678
|
}
|
|
682
679
|
}
|
|
683
680
|
if (key in options) {
|
|
684
681
|
var optionsValue = options[key];
|
|
685
|
-
utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
682
|
+
(0, utils_1.invariant)(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
686
683
|
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
687
684
|
if (optionsValue !== value) {
|
|
688
685
|
value = optionsValue;
|
|
@@ -724,7 +721,7 @@
|
|
|
724
721
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
725
722
|
var locale = requestedLocales_1[_i];
|
|
726
723
|
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
727
|
-
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
724
|
+
var availableLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(availableLocales, noExtensionLocale);
|
|
728
725
|
if (availableLocale) {
|
|
729
726
|
subset.push(availableLocale);
|
|
730
727
|
}
|
|
@@ -747,7 +744,7 @@
|
|
|
747
744
|
all.add(l);
|
|
748
745
|
return all;
|
|
749
746
|
}, new Set());
|
|
750
|
-
return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
|
|
747
|
+
return (0, ResolveLocale_1.ResolveLocale)(locales, requestedLocales, {
|
|
751
748
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
752
749
|
}, [], {}, function() {
|
|
753
750
|
return defaultLocale;
|
|
@@ -835,7 +832,7 @@
|
|
|
835
832
|
while (chunks.length && isUnicodeVariantSubtag(chunks[0])) {
|
|
836
833
|
var variant = chunks.shift();
|
|
837
834
|
if (variant in variants) {
|
|
838
|
-
throw new RangeError('Duplicate variant "'
|
|
835
|
+
throw new RangeError('Duplicate variant "'.concat(variant, '"'));
|
|
839
836
|
}
|
|
840
837
|
variants[variant] = 1;
|
|
841
838
|
}
|
|
@@ -906,7 +903,7 @@
|
|
|
906
903
|
value.push(chunks.shift());
|
|
907
904
|
}
|
|
908
905
|
if (!value.length) {
|
|
909
|
-
throw new RangeError('Missing tvalue for tkey "'
|
|
906
|
+
throw new RangeError('Missing tvalue for tkey "'.concat(key, '"'));
|
|
910
907
|
}
|
|
911
908
|
fields.push([key, value.join(exports.SEPARATOR)]);
|
|
912
909
|
}
|
|
@@ -983,7 +980,7 @@
|
|
|
983
980
|
throw new RangeError("Malformed extension type");
|
|
984
981
|
}
|
|
985
982
|
if (type in otherExtensionMap) {
|
|
986
|
-
throw new RangeError("There can only be 1 -"
|
|
983
|
+
throw new RangeError("There can only be 1 -".concat(type, "- extension"));
|
|
987
984
|
}
|
|
988
985
|
var extension = {
|
|
989
986
|
type: type,
|
|
@@ -999,7 +996,7 @@
|
|
|
999
996
|
function parseUnicodeLocaleId2(locale) {
|
|
1000
997
|
var chunks = locale.split(exports.SEPARATOR);
|
|
1001
998
|
var lang = parseUnicodeLanguageId2(chunks);
|
|
1002
|
-
return tslib_1.__assign({ lang: lang }, parseExtensions(chunks));
|
|
999
|
+
return (0, tslib_1.__assign)({ lang: lang }, parseExtensions(chunks));
|
|
1003
1000
|
}
|
|
1004
1001
|
exports.parseUnicodeLocaleId = parseUnicodeLocaleId2;
|
|
1005
1002
|
}
|
|
@@ -1016,7 +1013,7 @@
|
|
|
1016
1013
|
if (!lang) {
|
|
1017
1014
|
return "";
|
|
1018
1015
|
}
|
|
1019
|
-
return tslib_1.__spreadArray([lang.lang, lang.script, lang.region], lang.variants || []).filter(Boolean).join("-");
|
|
1016
|
+
return (0, tslib_1.__spreadArray)([lang.lang, lang.script, lang.region], lang.variants || [], true).filter(Boolean).join("-");
|
|
1020
1017
|
}
|
|
1021
1018
|
exports.emitUnicodeLanguageId = emitUnicodeLanguageId2;
|
|
1022
1019
|
function emitUnicodeLocaleId2(_a) {
|
|
@@ -1027,14 +1024,14 @@
|
|
|
1027
1024
|
chunks.push(ext.type);
|
|
1028
1025
|
switch (ext.type) {
|
|
1029
1026
|
case "u":
|
|
1030
|
-
chunks.push.apply(chunks, tslib_1.__spreadArray(tslib_1.__spreadArray([], ext.attributes), ext.keywords.reduce(function(all, kv) {
|
|
1027
|
+
chunks.push.apply(chunks, (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], ext.attributes, false), ext.keywords.reduce(function(all, kv) {
|
|
1031
1028
|
return all.concat(kv);
|
|
1032
|
-
}, [])));
|
|
1029
|
+
}, []), false));
|
|
1033
1030
|
break;
|
|
1034
1031
|
case "t":
|
|
1035
|
-
chunks.push.apply(chunks, tslib_1.__spreadArray([emitUnicodeLanguageId2(ext.lang)], ext.fields.reduce(function(all, kv) {
|
|
1032
|
+
chunks.push.apply(chunks, (0, tslib_1.__spreadArray)([emitUnicodeLanguageId2(ext.lang)], ext.fields.reduce(function(all, kv) {
|
|
1036
1033
|
return all.concat(kv);
|
|
1037
|
-
}, [])));
|
|
1034
|
+
}, []), false));
|
|
1038
1035
|
break;
|
|
1039
1036
|
default:
|
|
1040
1037
|
chunks.push(ext.value);
|
|
@@ -4096,7 +4093,7 @@
|
|
|
4096
4093
|
return e1.type < e2.type ? -1 : e1.type > e2.type ? 1 : 0;
|
|
4097
4094
|
}
|
|
4098
4095
|
function mergeVariants(v1, v2) {
|
|
4099
|
-
var result = tslib_1.__spreadArray([], v1);
|
|
4096
|
+
var result = (0, tslib_1.__spreadArray)([], v1, true);
|
|
4100
4097
|
for (var _i = 0, v2_1 = v2; _i < v2_1.length; _i++) {
|
|
4101
4098
|
var v = v2_1[_i];
|
|
4102
4099
|
if (v1.indexOf(v) < 0) {
|
|
@@ -4111,11 +4108,11 @@
|
|
|
4111
4108
|
var replacedLang_1 = "";
|
|
4112
4109
|
for (var _i = 0, _a = unicodeLanguageId.variants; _i < _a.length; _i++) {
|
|
4113
4110
|
var variant = _a[_i];
|
|
4114
|
-
if (replacedLang_1 = aliases_generated_1.languageAlias[emitter_1.emitUnicodeLanguageId({
|
|
4111
|
+
if (replacedLang_1 = aliases_generated_1.languageAlias[(0, emitter_1.emitUnicodeLanguageId)({
|
|
4115
4112
|
lang: unicodeLanguageId.lang,
|
|
4116
4113
|
variants: [variant]
|
|
4117
4114
|
})]) {
|
|
4118
|
-
var replacedLangAst = parser_1.parseUnicodeLanguageId(replacedLang_1.split(parser_1.SEPARATOR));
|
|
4115
|
+
var replacedLangAst = (0, parser_1.parseUnicodeLanguageId)(replacedLang_1.split(parser_1.SEPARATOR));
|
|
4119
4116
|
finalLangAst = {
|
|
4120
4117
|
lang: replacedLangAst.lang,
|
|
4121
4118
|
script: finalLangAst.script || replacedLangAst.script,
|
|
@@ -4127,14 +4124,14 @@
|
|
|
4127
4124
|
}
|
|
4128
4125
|
}
|
|
4129
4126
|
if (finalLangAst.script && finalLangAst.region) {
|
|
4130
|
-
var replacedLang_2 = aliases_generated_1.languageAlias[emitter_1.emitUnicodeLanguageId({
|
|
4127
|
+
var replacedLang_2 = aliases_generated_1.languageAlias[(0, emitter_1.emitUnicodeLanguageId)({
|
|
4131
4128
|
lang: finalLangAst.lang,
|
|
4132
4129
|
script: finalLangAst.script,
|
|
4133
4130
|
region: finalLangAst.region,
|
|
4134
4131
|
variants: []
|
|
4135
4132
|
})];
|
|
4136
4133
|
if (replacedLang_2) {
|
|
4137
|
-
var replacedLangAst = parser_1.parseUnicodeLanguageId(replacedLang_2.split(parser_1.SEPARATOR));
|
|
4134
|
+
var replacedLangAst = (0, parser_1.parseUnicodeLanguageId)(replacedLang_2.split(parser_1.SEPARATOR));
|
|
4138
4135
|
finalLangAst = {
|
|
4139
4136
|
lang: replacedLangAst.lang,
|
|
4140
4137
|
script: replacedLangAst.script,
|
|
@@ -4144,13 +4141,13 @@
|
|
|
4144
4141
|
}
|
|
4145
4142
|
}
|
|
4146
4143
|
if (finalLangAst.region) {
|
|
4147
|
-
var replacedLang_3 = aliases_generated_1.languageAlias[emitter_1.emitUnicodeLanguageId({
|
|
4144
|
+
var replacedLang_3 = aliases_generated_1.languageAlias[(0, emitter_1.emitUnicodeLanguageId)({
|
|
4148
4145
|
lang: finalLangAst.lang,
|
|
4149
4146
|
region: finalLangAst.region,
|
|
4150
4147
|
variants: []
|
|
4151
4148
|
})];
|
|
4152
4149
|
if (replacedLang_3) {
|
|
4153
|
-
var replacedLangAst = parser_1.parseUnicodeLanguageId(replacedLang_3.split(parser_1.SEPARATOR));
|
|
4150
|
+
var replacedLangAst = (0, parser_1.parseUnicodeLanguageId)(replacedLang_3.split(parser_1.SEPARATOR));
|
|
4154
4151
|
finalLangAst = {
|
|
4155
4152
|
lang: replacedLangAst.lang,
|
|
4156
4153
|
script: finalLangAst.script || replacedLangAst.script,
|
|
@@ -4159,12 +4156,12 @@
|
|
|
4159
4156
|
};
|
|
4160
4157
|
}
|
|
4161
4158
|
}
|
|
4162
|
-
var replacedLang = aliases_generated_1.languageAlias[emitter_1.emitUnicodeLanguageId({
|
|
4159
|
+
var replacedLang = aliases_generated_1.languageAlias[(0, emitter_1.emitUnicodeLanguageId)({
|
|
4163
4160
|
lang: finalLangAst.lang,
|
|
4164
4161
|
variants: []
|
|
4165
4162
|
})];
|
|
4166
4163
|
if (replacedLang) {
|
|
4167
|
-
var replacedLangAst = parser_1.parseUnicodeLanguageId(replacedLang.split(parser_1.SEPARATOR));
|
|
4164
|
+
var replacedLangAst = (0, parser_1.parseUnicodeLanguageId)(replacedLang.split(parser_1.SEPARATOR));
|
|
4168
4165
|
finalLangAst = {
|
|
4169
4166
|
lang: replacedLangAst.lang,
|
|
4170
4167
|
script: finalLangAst.script || replacedLangAst.script,
|
|
@@ -4179,13 +4176,13 @@
|
|
|
4179
4176
|
if (regionAlias) {
|
|
4180
4177
|
var regions = regionAlias.split(" ");
|
|
4181
4178
|
replacedRegion = regions[0];
|
|
4182
|
-
var likelySubtag = likelySubtags_generated_1.likelySubtags[emitter_1.emitUnicodeLanguageId({
|
|
4179
|
+
var likelySubtag = likelySubtags_generated_1.likelySubtags[(0, emitter_1.emitUnicodeLanguageId)({
|
|
4183
4180
|
lang: finalLangAst.lang,
|
|
4184
4181
|
script: finalLangAst.script,
|
|
4185
4182
|
variants: []
|
|
4186
4183
|
})];
|
|
4187
4184
|
if (likelySubtag) {
|
|
4188
|
-
var likelyRegion = parser_1.parseUnicodeLanguageId(likelySubtag.split(parser_1.SEPARATOR)).region;
|
|
4185
|
+
var likelyRegion = (0, parser_1.parseUnicodeLanguageId)(likelySubtag.split(parser_1.SEPARATOR)).region;
|
|
4189
4186
|
if (likelyRegion && regions.indexOf(likelyRegion) > -1) {
|
|
4190
4187
|
replacedRegion = likelyRegion;
|
|
4191
4188
|
}
|
|
@@ -4207,9 +4204,9 @@
|
|
|
4207
4204
|
var variant = finalLangAst.variants[i].toLowerCase();
|
|
4208
4205
|
if (aliases_generated_1.variantAlias[variant]) {
|
|
4209
4206
|
var alias = aliases_generated_1.variantAlias[variant];
|
|
4210
|
-
if (parser_1.isUnicodeVariantSubtag(alias)) {
|
|
4207
|
+
if ((0, parser_1.isUnicodeVariantSubtag)(alias)) {
|
|
4211
4208
|
finalLangAst.variants[i] = alias;
|
|
4212
|
-
} else if (parser_1.isUnicodeLanguageSubtag(alias)) {
|
|
4209
|
+
} else if ((0, parser_1.isUnicodeLanguageSubtag)(alias)) {
|
|
4213
4210
|
finalLangAst.lang = alias;
|
|
4214
4211
|
}
|
|
4215
4212
|
}
|
|
@@ -4278,7 +4275,7 @@
|
|
|
4278
4275
|
}
|
|
4279
4276
|
for (var _i = 0, locales_1 = locales; _i < locales_1.length; _i++) {
|
|
4280
4277
|
var locale = locales_1[_i];
|
|
4281
|
-
var canonicalizedTag = emitter_1.emitUnicodeLocaleId(canonicalizer_1.canonicalizeUnicodeLocaleId(parser_1.parseUnicodeLocaleId(locale)));
|
|
4278
|
+
var canonicalizedTag = (0, emitter_1.emitUnicodeLocaleId)((0, canonicalizer_1.canonicalizeUnicodeLocaleId)((0, parser_1.parseUnicodeLocaleId)(locale)));
|
|
4282
4279
|
if (seen.indexOf(canonicalizedTag) < 0) {
|
|
4283
4280
|
seen.push(canonicalizedTag);
|
|
4284
4281
|
}
|
|
@@ -4308,9 +4305,9 @@
|
|
|
4308
4305
|
Object.defineProperty(exports, "isUnicodeLanguageSubtag", { enumerable: true, get: function() {
|
|
4309
4306
|
return parser_2.isUnicodeLanguageSubtag;
|
|
4310
4307
|
} });
|
|
4311
|
-
tslib_1.__exportStar(require_types(), exports);
|
|
4312
|
-
tslib_1.__exportStar(require_emitter(), exports);
|
|
4313
|
-
tslib_1.__exportStar(require_likelySubtags_generated(), exports);
|
|
4308
|
+
(0, tslib_1.__exportStar)(require_types(), exports);
|
|
4309
|
+
(0, tslib_1.__exportStar)(require_emitter(), exports);
|
|
4310
|
+
(0, tslib_1.__exportStar)(require_likelySubtags_generated(), exports);
|
|
4314
4311
|
}
|
|
4315
4312
|
});
|
|
4316
4313
|
|
|
@@ -4372,7 +4369,7 @@
|
|
|
4372
4369
|
if (values !== void 0 && !values.filter(function(val) {
|
|
4373
4370
|
return val == value;
|
|
4374
4371
|
}).length) {
|
|
4375
|
-
throw new RangeError(value
|
|
4372
|
+
throw new RangeError("".concat(value, " is not within ").concat(values.join(", ")));
|
|
4376
4373
|
}
|
|
4377
4374
|
return value;
|
|
4378
4375
|
}
|
|
@@ -4444,8 +4441,8 @@
|
|
|
4444
4441
|
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]/;
|
|
4445
4442
|
|
|
4446
4443
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/format_to_parts.js
|
|
4447
|
-
var CARET_S_UNICODE_REGEX = new RegExp("^"
|
|
4448
|
-
var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source
|
|
4444
|
+
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
4445
|
+
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
4449
4446
|
|
|
4450
4447
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/InitializeNumberFormat.js
|
|
4451
4448
|
var import_intl_localematcher = __toModule(require_intl_localematcher());
|
|
@@ -4540,10 +4537,10 @@
|
|
|
4540
4537
|
value = entry[1];
|
|
4541
4538
|
}
|
|
4542
4539
|
}
|
|
4543
|
-
invariant(key in options, key
|
|
4540
|
+
invariant(key in options, "".concat(key, " must be in options"));
|
|
4544
4541
|
var optionsValue = options[key];
|
|
4545
4542
|
if (optionsValue !== void 0) {
|
|
4546
|
-
invariant(typeof optionsValue === "string", "Value for "
|
|
4543
|
+
invariant(typeof optionsValue === "string", "Value for ".concat(key, " must be a string"));
|
|
4547
4544
|
value = optionsValue;
|
|
4548
4545
|
if (entry) {
|
|
4549
4546
|
entry[1] = value;
|
|
@@ -4583,7 +4580,7 @@
|
|
|
4583
4580
|
lang: !lang || lang === "und" ? replacement.lang : lang,
|
|
4584
4581
|
script: script || replacement.script,
|
|
4585
4582
|
region: region || replacement.region,
|
|
4586
|
-
variants: (0, import_tslib2.__spreadArray)((0, import_tslib2.__spreadArray)([], variants), replacement.variants)
|
|
4583
|
+
variants: (0, import_tslib2.__spreadArray)((0, import_tslib2.__spreadArray)([], variants, true), replacement.variants, true)
|
|
4587
4584
|
};
|
|
4588
4585
|
}
|
|
4589
4586
|
function addLikelySubtags(tag) {
|
package/polyfill.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var _1 = require("./");
|
|
4
4
|
var should_polyfill_1 = require("./should-polyfill");
|
|
5
|
-
if (should_polyfill_1.shouldPolyfill()) {
|
|
5
|
+
if ((0, should_polyfill_1.shouldPolyfill)()) {
|
|
6
6
|
Object.defineProperty(Intl, 'Locale', {
|
|
7
7
|
value: _1.Locale,
|
|
8
8
|
writable: true,
|