@formatjs/intl-locale 3.4.0 → 3.4.2
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 +2 -1
- package/lib/calendars.generated.js +4 -1
- package/lib/character-orders.generated.js +4 -1
- package/lib/get_internal_slots.js +4 -1
- package/lib/hour-cycles.generated.js +4 -1
- package/lib/index.js +100 -96
- package/lib/numbering-systems.generated.js +4 -1
- package/lib/polyfill-force.js +4 -2
- package/lib/polyfill.js +6 -4
- package/lib/preference-data.js +25 -18
- package/lib/should-polyfill.js +5 -1
- package/lib/timezones.generated.js +4 -1
- package/lib/week-data.generated.js +4 -1
- package/package.json +4 -4
- package/polyfill.iife.js +15734 -8558
package/index.js
CHANGED
|
@@ -254,7 +254,7 @@ function weekInfoOfLocale(loc) {
|
|
|
254
254
|
}
|
|
255
255
|
return (0, preference_data_1.getWeekDataForRegion)(region);
|
|
256
256
|
}
|
|
257
|
-
var Locale =
|
|
257
|
+
var Locale = /** @class */ (function () {
|
|
258
258
|
function Locale(tag, opts) {
|
|
259
259
|
// test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
|
|
260
260
|
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
@@ -639,6 +639,7 @@ var Locale = exports.Locale = /** @class */ (function () {
|
|
|
639
639
|
Locale.polyfilled = true;
|
|
640
640
|
return Locale;
|
|
641
641
|
}());
|
|
642
|
+
exports.Locale = Locale;
|
|
642
643
|
try {
|
|
643
644
|
if (typeof Symbol !== 'undefined') {
|
|
644
645
|
Object.defineProperty(Locale.prototype, Symbol.toStringTag, {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.characterOrders = void 0;
|
|
1
4
|
/* @generated */
|
|
2
5
|
// prettier-ignore
|
|
3
|
-
|
|
6
|
+
exports.characterOrders = {
|
|
4
7
|
"aa": "left-to-right",
|
|
5
8
|
"aa-DJ": "left-to-right",
|
|
6
9
|
"aa-ER": "left-to-right",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Type-only circular import
|
|
2
3
|
// eslint-disable-next-line import/no-cycle
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
var internalSlotMap = new WeakMap();
|
|
4
|
-
|
|
6
|
+
function getInternalSlots(x) {
|
|
5
7
|
var internalSlots = internalSlotMap.get(x);
|
|
6
8
|
if (!internalSlots) {
|
|
7
9
|
internalSlots = Object.create(null);
|
|
@@ -9,3 +11,4 @@ export default function getInternalSlots(x) {
|
|
|
9
11
|
}
|
|
10
12
|
return internalSlots;
|
|
11
13
|
}
|
|
14
|
+
exports.default = getInternalSlots;
|
package/lib/index.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Locale = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var intl_enumerator_1 = require("@formatjs/intl-enumerator");
|
|
6
|
+
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
7
|
+
var intl_getcanonicallocales_1 = require("@formatjs/intl-getcanonicallocales");
|
|
8
|
+
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
9
|
+
var preference_data_1 = require("./preference-data");
|
|
10
|
+
var character_orders_generated_1 = require("./character-orders.generated");
|
|
11
|
+
var numbering_systems_generated_1 = require("./numbering-systems.generated");
|
|
9
12
|
var RELEVANT_EXTENSION_KEYS = ['ca', 'co', 'hc', 'kf', 'kn', 'nu'];
|
|
10
13
|
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
11
14
|
function applyOptionsToTag(tag, options) {
|
|
12
|
-
invariant(typeof tag === 'string', 'language tag must be a string');
|
|
13
|
-
invariant(isStructurallyValidLanguageTag(tag), 'malformed language tag', RangeError);
|
|
14
|
-
var language = GetOption(options, 'language', 'string', undefined, undefined);
|
|
15
|
+
(0, ecma402_abstract_1.invariant)(typeof tag === 'string', 'language tag must be a string');
|
|
16
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isStructurallyValidLanguageTag)(tag), 'malformed language tag', RangeError);
|
|
17
|
+
var language = (0, ecma402_abstract_1.GetOption)(options, 'language', 'string', undefined, undefined);
|
|
15
18
|
if (language !== undefined) {
|
|
16
|
-
invariant(isUnicodeLanguageSubtag(language), 'Malformed unicode_language_subtag', RangeError);
|
|
19
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeLanguageSubtag)(language), 'Malformed unicode_language_subtag', RangeError);
|
|
17
20
|
}
|
|
18
|
-
var script = GetOption(options, 'script', 'string', undefined, undefined);
|
|
21
|
+
var script = (0, ecma402_abstract_1.GetOption)(options, 'script', 'string', undefined, undefined);
|
|
19
22
|
if (script !== undefined) {
|
|
20
|
-
invariant(isUnicodeScriptSubtag(script), 'Malformed unicode_script_subtag', RangeError);
|
|
23
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeScriptSubtag)(script), 'Malformed unicode_script_subtag', RangeError);
|
|
21
24
|
}
|
|
22
|
-
var region = GetOption(options, 'region', 'string', undefined, undefined);
|
|
25
|
+
var region = (0, ecma402_abstract_1.GetOption)(options, 'region', 'string', undefined, undefined);
|
|
23
26
|
if (region !== undefined) {
|
|
24
|
-
invariant(isUnicodeRegionSubtag(region), 'Malformed unicode_region_subtag', RangeError);
|
|
27
|
+
(0, ecma402_abstract_1.invariant)((0, intl_getcanonicallocales_1.isUnicodeRegionSubtag)(region), 'Malformed unicode_region_subtag', RangeError);
|
|
25
28
|
}
|
|
26
|
-
var languageId = parseUnicodeLanguageId(tag);
|
|
29
|
+
var languageId = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(tag);
|
|
27
30
|
if (language !== undefined) {
|
|
28
31
|
languageId.lang = language;
|
|
29
32
|
}
|
|
@@ -33,12 +36,12 @@ function applyOptionsToTag(tag, options) {
|
|
|
33
36
|
if (region !== undefined) {
|
|
34
37
|
languageId.region = region;
|
|
35
38
|
}
|
|
36
|
-
return Intl.getCanonicalLocales(emitUnicodeLocaleId(__assign(__assign({}, parseUnicodeLocaleId(tag)), { lang: languageId })))[0];
|
|
39
|
+
return Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag)), { lang: languageId })))[0];
|
|
37
40
|
}
|
|
38
41
|
function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
39
42
|
var unicodeExtension;
|
|
40
43
|
var keywords = [];
|
|
41
|
-
var ast = parseUnicodeLocaleId(tag);
|
|
44
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
42
45
|
for (var _i = 0, _a = ast.extensions; _i < _a.length; _i++) {
|
|
43
46
|
var ext = _a[_i];
|
|
44
47
|
if (ext.type === 'u') {
|
|
@@ -58,10 +61,10 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
58
61
|
value = entry[1];
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
invariant(key in options, "".concat(key, " must be in options"));
|
|
64
|
+
(0, ecma402_abstract_1.invariant)(key in options, "".concat(key, " must be in options"));
|
|
62
65
|
var optionsValue = options[key];
|
|
63
66
|
if (optionsValue !== undefined) {
|
|
64
|
-
invariant(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
|
|
67
|
+
(0, ecma402_abstract_1.invariant)(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
|
|
65
68
|
value = optionsValue;
|
|
66
69
|
if (entry) {
|
|
67
70
|
entry[1] = value;
|
|
@@ -84,7 +87,7 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
84
87
|
else {
|
|
85
88
|
unicodeExtension.keywords = keywords;
|
|
86
89
|
}
|
|
87
|
-
result.locale = Intl.getCanonicalLocales(emitUnicodeLocaleId(ast))[0];
|
|
90
|
+
result.locale = Intl.getCanonicalLocales((0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast))[0];
|
|
88
91
|
return result;
|
|
89
92
|
}
|
|
90
93
|
function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
@@ -101,45 +104,45 @@ function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
|
101
104
|
lang: !lang || lang === 'und' ? replacement.lang : lang,
|
|
102
105
|
script: script || replacement.script,
|
|
103
106
|
region: region || replacement.region,
|
|
104
|
-
variants: __spreadArray(__spreadArray([], variants, true), replacement.variants, true),
|
|
107
|
+
variants: tslib_1.__spreadArray(tslib_1.__spreadArray([], variants, true), replacement.variants, true),
|
|
105
108
|
};
|
|
106
109
|
}
|
|
107
110
|
function addLikelySubtags(tag) {
|
|
108
|
-
var ast = parseUnicodeLocaleId(tag);
|
|
111
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
109
112
|
var unicodeLangId = ast.lang;
|
|
110
113
|
var lang = unicodeLangId.lang, script = unicodeLangId.script, region = unicodeLangId.region, variants = unicodeLangId.variants;
|
|
111
114
|
if (script && region) {
|
|
112
|
-
var match_1 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, region: region, variants: [] })];
|
|
115
|
+
var match_1 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, region: region, variants: [] })];
|
|
113
116
|
if (match_1) {
|
|
114
|
-
var parts_1 = parseUnicodeLanguageId(match_1);
|
|
117
|
+
var parts_1 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_1);
|
|
115
118
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, undefined, variants, parts_1);
|
|
116
|
-
return emitUnicodeLocaleId(ast);
|
|
119
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
if (script) {
|
|
120
|
-
var match_2 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, variants: [] })];
|
|
123
|
+
var match_2 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] })];
|
|
121
124
|
if (match_2) {
|
|
122
|
-
var parts_2 = parseUnicodeLanguageId(match_2);
|
|
125
|
+
var parts_2 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_2);
|
|
123
126
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, region, variants, parts_2);
|
|
124
|
-
return emitUnicodeLocaleId(ast);
|
|
127
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
125
128
|
}
|
|
126
129
|
}
|
|
127
130
|
if (region) {
|
|
128
|
-
var match_3 = likelySubtags[emitUnicodeLanguageId({ lang: lang, region: region, variants: [] })];
|
|
131
|
+
var match_3 = intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] })];
|
|
129
132
|
if (match_3) {
|
|
130
|
-
var parts_3 = parseUnicodeLanguageId(match_3);
|
|
133
|
+
var parts_3 = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match_3);
|
|
131
134
|
ast.lang = mergeUnicodeLanguageId(undefined, script, undefined, variants, parts_3);
|
|
132
|
-
return emitUnicodeLocaleId(ast);
|
|
135
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
|
-
var match = likelySubtags[lang] ||
|
|
136
|
-
likelySubtags[emitUnicodeLanguageId({ lang: 'und', script: script, variants: [] })];
|
|
138
|
+
var match = intl_getcanonicallocales_1.likelySubtags[lang] ||
|
|
139
|
+
intl_getcanonicallocales_1.likelySubtags[(0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: 'und', script: script, variants: [] })];
|
|
137
140
|
if (!match) {
|
|
138
141
|
throw new Error("No match for addLikelySubtags");
|
|
139
142
|
}
|
|
140
|
-
var parts = parseUnicodeLanguageId(match);
|
|
143
|
+
var parts = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(match);
|
|
141
144
|
ast.lang = mergeUnicodeLanguageId(undefined, script, region, variants, parts);
|
|
142
|
-
return emitUnicodeLocaleId(ast);
|
|
145
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(ast);
|
|
143
146
|
}
|
|
144
147
|
/**
|
|
145
148
|
* From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
|
|
@@ -150,23 +153,23 @@ function removeLikelySubtags(tag) {
|
|
|
150
153
|
if (!maxLocale) {
|
|
151
154
|
return tag;
|
|
152
155
|
}
|
|
153
|
-
maxLocale = emitUnicodeLanguageId(__assign(__assign({}, parseUnicodeLanguageId(maxLocale)), { variants: [] }));
|
|
154
|
-
var ast = parseUnicodeLocaleId(tag);
|
|
156
|
+
maxLocale = (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)(tslib_1.__assign(tslib_1.__assign({}, (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(maxLocale)), { variants: [] }));
|
|
157
|
+
var ast = (0, intl_getcanonicallocales_1.parseUnicodeLocaleId)(tag);
|
|
155
158
|
var _a = ast.lang, lang = _a.lang, script = _a.script, region = _a.region, variants = _a.variants;
|
|
156
|
-
var trial = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, variants: [] }));
|
|
159
|
+
var trial = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, variants: [] }));
|
|
157
160
|
if (trial === maxLocale) {
|
|
158
|
-
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
|
|
161
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
|
|
159
162
|
}
|
|
160
163
|
if (region) {
|
|
161
|
-
var trial_1 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, region: region, variants: [] }));
|
|
164
|
+
var trial_1 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, region: region, variants: [] }));
|
|
162
165
|
if (trial_1 === maxLocale) {
|
|
163
|
-
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
|
|
166
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
169
|
if (script) {
|
|
167
|
-
var trial_2 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, script: script, variants: [] }));
|
|
170
|
+
var trial_2 = addLikelySubtags((0, intl_getcanonicallocales_1.emitUnicodeLanguageId)({ lang: lang, script: script, variants: [] }));
|
|
168
171
|
if (trial_2 === maxLocale) {
|
|
169
|
-
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
|
|
172
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLocaleId)(tslib_1.__assign(tslib_1.__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
return tag;
|
|
@@ -179,55 +182,55 @@ function createArrayFromListOrRestricted(list, restricted) {
|
|
|
179
182
|
return Array.from(result);
|
|
180
183
|
}
|
|
181
184
|
function calendarsOfLocale(loc) {
|
|
182
|
-
var locInternalSlots =
|
|
185
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
183
186
|
var restricted = locInternalSlots.calendar;
|
|
184
187
|
var locale = locInternalSlots.locale;
|
|
185
188
|
var region;
|
|
186
189
|
if (locale !== 'root') {
|
|
187
190
|
region = loc.maximize().region;
|
|
188
191
|
}
|
|
189
|
-
var preferredCalendars = getCalendarPreferenceDataForRegion(region);
|
|
192
|
+
var preferredCalendars = (0, preference_data_1.getCalendarPreferenceDataForRegion)(region);
|
|
190
193
|
return createArrayFromListOrRestricted(preferredCalendars, restricted);
|
|
191
194
|
}
|
|
192
195
|
function collationsOfLocale(loc) {
|
|
193
|
-
var locInternalSlots =
|
|
196
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
194
197
|
var restricted = locInternalSlots.collation;
|
|
195
198
|
var locale = locInternalSlots.locale;
|
|
196
|
-
var supportedCollations = supportedValuesOf('collation', locale).filter(function (co) { return co !== 'standard' && co !== 'search'; });
|
|
199
|
+
var supportedCollations = (0, intl_enumerator_1.supportedValuesOf)('collation', locale).filter(function (co) { return co !== 'standard' && co !== 'search'; });
|
|
197
200
|
supportedCollations.sort();
|
|
198
201
|
return createArrayFromListOrRestricted(supportedCollations, restricted);
|
|
199
202
|
}
|
|
200
203
|
function hourCyclesOfLocale(loc) {
|
|
201
|
-
var locInternalSlots =
|
|
204
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
202
205
|
var restricted = locInternalSlots.hourCycle;
|
|
203
206
|
var locale = locInternalSlots.locale;
|
|
204
207
|
var region;
|
|
205
208
|
if (locale !== 'root') {
|
|
206
209
|
region = loc.maximize().region;
|
|
207
210
|
}
|
|
208
|
-
var preferredHourCycles = getHourCyclesPreferenceDataForLocaleOrRegion(locale, region);
|
|
211
|
+
var preferredHourCycles = (0, preference_data_1.getHourCyclesPreferenceDataForLocaleOrRegion)(locale, region);
|
|
209
212
|
return createArrayFromListOrRestricted(preferredHourCycles, restricted);
|
|
210
213
|
}
|
|
211
214
|
function numberingSystemsOfLocale(loc) {
|
|
212
215
|
var _a;
|
|
213
|
-
var locInternalSlots =
|
|
216
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
214
217
|
var restricted = locInternalSlots.numberingSystem;
|
|
215
218
|
var locale = locInternalSlots.locale;
|
|
216
219
|
var language = loc.language;
|
|
217
|
-
var localeNumberingSystems = (_a = numberingSystems[locale]) !== null && _a !== void 0 ? _a : numberingSystems[language];
|
|
220
|
+
var localeNumberingSystems = (_a = numbering_systems_generated_1.numberingSystems[locale]) !== null && _a !== void 0 ? _a : numbering_systems_generated_1.numberingSystems[language];
|
|
218
221
|
if (localeNumberingSystems) {
|
|
219
|
-
return createArrayFromListOrRestricted(__spreadArray([], localeNumberingSystems, true), restricted);
|
|
222
|
+
return createArrayFromListOrRestricted(tslib_1.__spreadArray([], localeNumberingSystems, true), restricted);
|
|
220
223
|
}
|
|
221
224
|
return createArrayFromListOrRestricted([], restricted);
|
|
222
225
|
}
|
|
223
226
|
function timeZonesOfLocale(loc) {
|
|
224
|
-
var locInternalSlots =
|
|
227
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
225
228
|
var locale = locInternalSlots.locale;
|
|
226
|
-
var region = parseUnicodeLanguageId(locale).region;
|
|
229
|
+
var region = (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).region;
|
|
227
230
|
if (!region) {
|
|
228
231
|
return undefined;
|
|
229
232
|
}
|
|
230
|
-
var preferredTimeZones = getTimeZonePreferenceForRegion(region);
|
|
233
|
+
var preferredTimeZones = (0, preference_data_1.getTimeZonePreferenceForRegion)(region);
|
|
231
234
|
preferredTimeZones.sort();
|
|
232
235
|
return Array.from(preferredTimeZones);
|
|
233
236
|
}
|
|
@@ -238,20 +241,20 @@ function translateCharacterOrder(order) {
|
|
|
238
241
|
return 'ltr';
|
|
239
242
|
}
|
|
240
243
|
function characterDirectionOfLocale(loc) {
|
|
241
|
-
var locInternalSlots =
|
|
244
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
242
245
|
var locale = locInternalSlots.locale;
|
|
243
|
-
return translateCharacterOrder(characterOrders[locale]);
|
|
246
|
+
return translateCharacterOrder(character_orders_generated_1.characterOrders[locale]);
|
|
244
247
|
}
|
|
245
248
|
function weekInfoOfLocale(loc) {
|
|
246
|
-
var locInternalSlots =
|
|
249
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(loc);
|
|
247
250
|
var locale = locInternalSlots.locale;
|
|
248
251
|
var region;
|
|
249
252
|
if (locale !== 'root') {
|
|
250
253
|
region = loc.maximize().region;
|
|
251
254
|
}
|
|
252
|
-
return getWeekDataForRegion(region);
|
|
255
|
+
return (0, preference_data_1.getWeekDataForRegion)(region);
|
|
253
256
|
}
|
|
254
|
-
|
|
257
|
+
var Locale = /** @class */ (function () {
|
|
255
258
|
function Locale(tag, opts) {
|
|
256
259
|
// test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
|
|
257
260
|
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
@@ -282,42 +285,42 @@ export var Locale = /** @class */ (function () {
|
|
|
282
285
|
}
|
|
283
286
|
var internalSlots;
|
|
284
287
|
if (typeof tag === 'object' &&
|
|
285
|
-
(internalSlots =
|
|
288
|
+
(internalSlots = (0, get_internal_slots_1.default)(tag)) &&
|
|
286
289
|
internalSlots.initializedLocale) {
|
|
287
290
|
tag = internalSlots.locale;
|
|
288
291
|
}
|
|
289
292
|
else {
|
|
290
293
|
tag = tag.toString();
|
|
291
294
|
}
|
|
292
|
-
internalSlots =
|
|
293
|
-
var options = CoerceOptionsToObject(opts);
|
|
295
|
+
internalSlots = (0, get_internal_slots_1.default)(this);
|
|
296
|
+
var options = (0, ecma402_abstract_1.CoerceOptionsToObject)(opts);
|
|
294
297
|
tag = applyOptionsToTag(tag, options);
|
|
295
298
|
var opt = Object.create(null);
|
|
296
|
-
var calendar = GetOption(options, 'calendar', 'string', undefined, undefined);
|
|
299
|
+
var calendar = (0, ecma402_abstract_1.GetOption)(options, 'calendar', 'string', undefined, undefined);
|
|
297
300
|
if (calendar !== undefined) {
|
|
298
301
|
if (!UNICODE_TYPE_REGEX.test(calendar)) {
|
|
299
302
|
throw new RangeError('invalid calendar');
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
opt.ca = calendar;
|
|
303
|
-
var collation = GetOption(options, 'collation', 'string', undefined, undefined);
|
|
306
|
+
var collation = (0, ecma402_abstract_1.GetOption)(options, 'collation', 'string', undefined, undefined);
|
|
304
307
|
if (collation !== undefined) {
|
|
305
308
|
if (!UNICODE_TYPE_REGEX.test(collation)) {
|
|
306
309
|
throw new RangeError('invalid collation');
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
opt.co = collation;
|
|
310
|
-
var hc = GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
313
|
+
var hc = (0, ecma402_abstract_1.GetOption)(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
311
314
|
opt.hc = hc;
|
|
312
|
-
var kf = GetOption(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
315
|
+
var kf = (0, ecma402_abstract_1.GetOption)(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
313
316
|
opt.kf = kf;
|
|
314
|
-
var _kn = GetOption(options, 'numeric', 'boolean', undefined, undefined);
|
|
317
|
+
var _kn = (0, ecma402_abstract_1.GetOption)(options, 'numeric', 'boolean', undefined, undefined);
|
|
315
318
|
var kn;
|
|
316
319
|
if (_kn !== undefined) {
|
|
317
320
|
kn = String(_kn);
|
|
318
321
|
}
|
|
319
322
|
opt.kn = kn;
|
|
320
|
-
var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
|
|
323
|
+
var numberingSystem = (0, ecma402_abstract_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
|
|
321
324
|
if (numberingSystem !== undefined) {
|
|
322
325
|
if (!UNICODE_TYPE_REGEX.test(numberingSystem)) {
|
|
323
326
|
throw new RangeError('Invalid numberingSystem');
|
|
@@ -333,7 +336,7 @@ export var Locale = /** @class */ (function () {
|
|
|
333
336
|
internalSlots.caseFirst = r.kf;
|
|
334
337
|
}
|
|
335
338
|
if (relevantExtensionKeys.indexOf('kn') > -1) {
|
|
336
|
-
internalSlots.numeric = SameValue(r.kn, 'true');
|
|
339
|
+
internalSlots.numeric = (0, ecma402_abstract_1.SameValue)(r.kn, 'true');
|
|
337
340
|
}
|
|
338
341
|
internalSlots.numberingSystem = r.nu;
|
|
339
342
|
}
|
|
@@ -341,7 +344,7 @@ export var Locale = /** @class */ (function () {
|
|
|
341
344
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
342
345
|
*/
|
|
343
346
|
Locale.prototype.maximize = function () {
|
|
344
|
-
var locale =
|
|
347
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
345
348
|
try {
|
|
346
349
|
var maximizedLocale = addLikelySubtags(locale);
|
|
347
350
|
return new Locale(maximizedLocale);
|
|
@@ -354,7 +357,7 @@ export var Locale = /** @class */ (function () {
|
|
|
354
357
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
355
358
|
*/
|
|
356
359
|
Locale.prototype.minimize = function () {
|
|
357
|
-
var locale =
|
|
360
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
358
361
|
try {
|
|
359
362
|
var minimizedLocale = removeLikelySubtags(locale);
|
|
360
363
|
return new Locale(minimizedLocale);
|
|
@@ -364,54 +367,54 @@ export var Locale = /** @class */ (function () {
|
|
|
364
367
|
}
|
|
365
368
|
};
|
|
366
369
|
Locale.prototype.toString = function () {
|
|
367
|
-
return
|
|
370
|
+
return (0, get_internal_slots_1.default)(this).locale;
|
|
368
371
|
};
|
|
369
372
|
Object.defineProperty(Locale.prototype, "baseName", {
|
|
370
373
|
get: function () {
|
|
371
|
-
var locale =
|
|
372
|
-
return emitUnicodeLanguageId(parseUnicodeLanguageId(locale));
|
|
374
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
375
|
+
return (0, intl_getcanonicallocales_1.emitUnicodeLanguageId)((0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale));
|
|
373
376
|
},
|
|
374
377
|
enumerable: false,
|
|
375
378
|
configurable: true
|
|
376
379
|
});
|
|
377
380
|
Object.defineProperty(Locale.prototype, "calendar", {
|
|
378
381
|
get: function () {
|
|
379
|
-
return
|
|
382
|
+
return (0, get_internal_slots_1.default)(this).calendar;
|
|
380
383
|
},
|
|
381
384
|
enumerable: false,
|
|
382
385
|
configurable: true
|
|
383
386
|
});
|
|
384
387
|
Object.defineProperty(Locale.prototype, "collation", {
|
|
385
388
|
get: function () {
|
|
386
|
-
return
|
|
389
|
+
return (0, get_internal_slots_1.default)(this).collation;
|
|
387
390
|
},
|
|
388
391
|
enumerable: false,
|
|
389
392
|
configurable: true
|
|
390
393
|
});
|
|
391
394
|
Object.defineProperty(Locale.prototype, "hourCycle", {
|
|
392
395
|
get: function () {
|
|
393
|
-
return
|
|
396
|
+
return (0, get_internal_slots_1.default)(this).hourCycle;
|
|
394
397
|
},
|
|
395
398
|
enumerable: false,
|
|
396
399
|
configurable: true
|
|
397
400
|
});
|
|
398
401
|
Object.defineProperty(Locale.prototype, "caseFirst", {
|
|
399
402
|
get: function () {
|
|
400
|
-
return
|
|
403
|
+
return (0, get_internal_slots_1.default)(this).caseFirst;
|
|
401
404
|
},
|
|
402
405
|
enumerable: false,
|
|
403
406
|
configurable: true
|
|
404
407
|
});
|
|
405
408
|
Object.defineProperty(Locale.prototype, "numeric", {
|
|
406
409
|
get: function () {
|
|
407
|
-
return
|
|
410
|
+
return (0, get_internal_slots_1.default)(this).numeric;
|
|
408
411
|
},
|
|
409
412
|
enumerable: false,
|
|
410
413
|
configurable: true
|
|
411
414
|
});
|
|
412
415
|
Object.defineProperty(Locale.prototype, "numberingSystem", {
|
|
413
416
|
get: function () {
|
|
414
|
-
return
|
|
417
|
+
return (0, get_internal_slots_1.default)(this).numberingSystem;
|
|
415
418
|
},
|
|
416
419
|
enumerable: false,
|
|
417
420
|
configurable: true
|
|
@@ -421,8 +424,8 @@ export var Locale = /** @class */ (function () {
|
|
|
421
424
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.language
|
|
422
425
|
*/
|
|
423
426
|
get: function () {
|
|
424
|
-
var locale =
|
|
425
|
-
return parseUnicodeLanguageId(locale).lang;
|
|
427
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
428
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).lang;
|
|
426
429
|
},
|
|
427
430
|
enumerable: false,
|
|
428
431
|
configurable: true
|
|
@@ -432,8 +435,8 @@ export var Locale = /** @class */ (function () {
|
|
|
432
435
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.script
|
|
433
436
|
*/
|
|
434
437
|
get: function () {
|
|
435
|
-
var locale =
|
|
436
|
-
return parseUnicodeLanguageId(locale).script;
|
|
438
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
439
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).script;
|
|
437
440
|
},
|
|
438
441
|
enumerable: false,
|
|
439
442
|
configurable: true
|
|
@@ -443,8 +446,8 @@ export var Locale = /** @class */ (function () {
|
|
|
443
446
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
|
|
444
447
|
*/
|
|
445
448
|
get: function () {
|
|
446
|
-
var locale =
|
|
447
|
-
return parseUnicodeLanguageId(locale).region;
|
|
449
|
+
var locale = (0, get_internal_slots_1.default)(this).locale;
|
|
450
|
+
return (0, intl_getcanonicallocales_1.parseUnicodeLanguageId)(locale).region;
|
|
448
451
|
},
|
|
449
452
|
enumerable: false,
|
|
450
453
|
configurable: true
|
|
@@ -488,7 +491,7 @@ export var Locale = /** @class */ (function () {
|
|
|
488
491
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
|
|
489
492
|
*/
|
|
490
493
|
Locale.prototype.getHourCycles = function () {
|
|
491
|
-
var locInternalSlots =
|
|
494
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(this);
|
|
492
495
|
if (locInternalSlots.initializedLocale === undefined) {
|
|
493
496
|
throw new TypeError('Error uninitialized locale');
|
|
494
497
|
}
|
|
@@ -545,7 +548,7 @@ export var Locale = /** @class */ (function () {
|
|
|
545
548
|
Locale.prototype.getTextInfo = function () {
|
|
546
549
|
var info = Object.create(Object.prototype);
|
|
547
550
|
var dir = characterDirectionOfLocale(this);
|
|
548
|
-
defineProperty(info, 'direction', {
|
|
551
|
+
(0, ecma402_abstract_1.defineProperty)(info, 'direction', {
|
|
549
552
|
value: dir,
|
|
550
553
|
});
|
|
551
554
|
return info;
|
|
@@ -579,19 +582,19 @@ export var Locale = /** @class */ (function () {
|
|
|
579
582
|
*/
|
|
580
583
|
Locale.prototype.getWeekInfo = function () {
|
|
581
584
|
var info = Object.create(Object.prototype);
|
|
582
|
-
var locInternalSlots =
|
|
585
|
+
var locInternalSlots = (0, get_internal_slots_1.default)(this);
|
|
583
586
|
if (locInternalSlots.initializedLocale === undefined) {
|
|
584
587
|
throw new TypeError('Error uninitialized locale');
|
|
585
588
|
}
|
|
586
589
|
var wi = weekInfoOfLocale(this);
|
|
587
590
|
var we = wi.weekend;
|
|
588
|
-
defineProperty(info, 'firstDay', {
|
|
591
|
+
(0, ecma402_abstract_1.defineProperty)(info, 'firstDay', {
|
|
589
592
|
value: wi.firstDay,
|
|
590
593
|
});
|
|
591
|
-
defineProperty(info, 'weekend', {
|
|
594
|
+
(0, ecma402_abstract_1.defineProperty)(info, 'weekend', {
|
|
592
595
|
value: we,
|
|
593
596
|
});
|
|
594
|
-
defineProperty(info, 'minimalDays', {
|
|
597
|
+
(0, ecma402_abstract_1.defineProperty)(info, 'minimalDays', {
|
|
595
598
|
value: wi.minimalDays,
|
|
596
599
|
});
|
|
597
600
|
return info;
|
|
@@ -636,6 +639,7 @@ export var Locale = /** @class */ (function () {
|
|
|
636
639
|
Locale.polyfilled = true;
|
|
637
640
|
return Locale;
|
|
638
641
|
}());
|
|
642
|
+
exports.Locale = Locale;
|
|
639
643
|
try {
|
|
640
644
|
if (typeof Symbol !== 'undefined') {
|
|
641
645
|
Object.defineProperty(Locale.prototype, Symbol.toStringTag, {
|
|
@@ -655,4 +659,4 @@ try {
|
|
|
655
659
|
catch (e) {
|
|
656
660
|
// Meta fix so we're test262-compliant, not important
|
|
657
661
|
}
|
|
658
|
-
|
|
662
|
+
exports.default = Locale;
|
package/lib/polyfill-force.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var _1 = require("./");
|
|
2
4
|
Object.defineProperty(Intl, 'Locale', {
|
|
3
|
-
value: Locale,
|
|
5
|
+
value: _1.Locale,
|
|
4
6
|
writable: true,
|
|
5
7
|
enumerable: false,
|
|
6
8
|
configurable: true,
|
package/lib/polyfill.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var _1 = require("./");
|
|
4
|
+
var should_polyfill_1 = require("./should-polyfill");
|
|
5
|
+
if ((0, should_polyfill_1.shouldPolyfill)()) {
|
|
4
6
|
Object.defineProperty(Intl, 'Locale', {
|
|
5
|
-
value: Locale,
|
|
7
|
+
value: _1.Locale,
|
|
6
8
|
writable: true,
|
|
7
9
|
enumerable: false,
|
|
8
10
|
configurable: true,
|