@formatjs/intl-locale 4.2.13 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/calendars.generated.js +1 -4
- package/character-orders.generated.js +1 -4
- package/get_internal_slots.js +1 -4
- package/hour-cycles.generated.js +1 -4
- package/index.js +105 -108
- package/numbering-systems.generated.js +1 -4
- package/package.json +11 -5
- package/polyfill-force.js +2 -4
- package/polyfill.iife.js +8281 -20618
- package/polyfill.js +4 -6
- package/preference-data.d.ts +1 -1
- package/preference-data.js +18 -24
- package/should-polyfill.js +2 -5
- package/timezones.generated.js +1 -4
- package/week-data.generated.js +1 -4
- package/lib/calendars.generated.d.ts +0 -55
- package/lib/calendars.generated.js +0 -292
- package/lib/character-orders.generated.d.ts +0 -729
- package/lib/character-orders.generated.js +0 -729
- package/lib/get_internal_slots.d.ts +0 -2
- package/lib/get_internal_slots.js +0 -19
- package/lib/hour-cycles.generated.d.ts +0 -277
- package/lib/hour-cycles.generated.js +0 -1041
- package/lib/index.d.ts +0 -103
- package/lib/index.js +0 -582
- package/lib/numbering-systems.generated.d.ts +0 -728
- package/lib/numbering-systems.generated.js +0 -2299
- package/lib/polyfill-force.d.ts +0 -1
- package/lib/polyfill-force.js +0 -7
- package/lib/polyfill.d.ts +0 -1
- package/lib/polyfill.js +0 -10
- package/lib/preference-data.d.ts +0 -6
- package/lib/preference-data.js +0 -46
- package/lib/should-polyfill.d.ts +0 -1
- package/lib/should-polyfill.js +0 -14
- package/lib/timezones.generated.d.ts +0 -250
- package/lib/timezones.generated.js +0 -966
- package/lib/week-data.generated.d.ts +0 -1299
- package/lib/week-data.generated.js +0 -2073
package/calendars.generated.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.characterOrders = void 0;
|
|
4
1
|
/* @generated */
|
|
5
2
|
// prettier-ignore
|
|
6
|
-
|
|
3
|
+
export var characterOrders = {
|
|
7
4
|
"aa": "left-to-right",
|
|
8
5
|
"aa-DJ": "left-to-right",
|
|
9
6
|
"aa-ER": "left-to-right",
|
package/get_internal_slots.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Type-only circular import
|
|
3
2
|
// eslint-disable-next-line import/no-cycle
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.default = getInternalSlots;
|
|
6
3
|
var internalSlotMap = new WeakMap();
|
|
7
|
-
function getInternalSlots(x, internalSlotsList) {
|
|
4
|
+
export default function getInternalSlots(x, internalSlotsList) {
|
|
8
5
|
if (internalSlotsList === void 0) { internalSlotsList = []; }
|
|
9
6
|
var internalSlots = internalSlotMap.get(x);
|
|
10
7
|
if (!internalSlots) {
|
package/hour-cycles.generated.js
CHANGED
package/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
|
|
10
|
-
var numbering_systems_generated_1 = require("./numbering-systems.generated");
|
|
11
|
-
var preference_data_1 = require("./preference-data");
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { CoerceOptionsToObject, GetOption, HasOwnProperty, SameValue, createDataProperty, invariant, } from '@formatjs/ecma402-abstract';
|
|
3
|
+
import { supportedValuesOf } from '@formatjs/intl-enumerator';
|
|
4
|
+
import { emitUnicodeLanguageId, emitUnicodeLocaleId, isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, likelySubtags, parseUnicodeLanguageId, parseUnicodeLocaleId, } from '@formatjs/intl-getcanonicallocales';
|
|
5
|
+
import { characterOrders } from './character-orders.generated.js';
|
|
6
|
+
import getInternalSlots from './get_internal_slots.js';
|
|
7
|
+
import { numberingSystems } from './numbering-systems.generated.js';
|
|
8
|
+
import { getCalendarPreferenceDataForRegion, getHourCyclesPreferenceDataForLocaleOrRegion, getTimeZonePreferenceForRegion, getWeekDataForRegion, } from './preference-data.js';
|
|
12
9
|
var ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
|
|
13
10
|
var RELEVANT_EXTENSION_KEYS = [
|
|
14
11
|
'ca',
|
|
@@ -21,21 +18,21 @@ var RELEVANT_EXTENSION_KEYS = [
|
|
|
21
18
|
];
|
|
22
19
|
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
23
20
|
function applyOptionsToTag(tag, options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var language =
|
|
21
|
+
invariant(typeof tag === 'string', 'language tag must be a string');
|
|
22
|
+
invariant(isStructurallyValidLanguageTag(tag), 'malformed language tag', RangeError);
|
|
23
|
+
var language = GetOption(options, 'language', 'string', undefined, undefined);
|
|
27
24
|
if (language !== undefined) {
|
|
28
|
-
|
|
25
|
+
invariant(isUnicodeLanguageSubtag(language), 'Malformed unicode_language_subtag', RangeError);
|
|
29
26
|
}
|
|
30
|
-
var script =
|
|
27
|
+
var script = GetOption(options, 'script', 'string', undefined, undefined);
|
|
31
28
|
if (script !== undefined) {
|
|
32
|
-
|
|
29
|
+
invariant(isUnicodeScriptSubtag(script), 'Malformed unicode_script_subtag', RangeError);
|
|
33
30
|
}
|
|
34
|
-
var region =
|
|
31
|
+
var region = GetOption(options, 'region', 'string', undefined, undefined);
|
|
35
32
|
if (region !== undefined) {
|
|
36
|
-
|
|
33
|
+
invariant(isUnicodeRegionSubtag(region), 'Malformed unicode_region_subtag', RangeError);
|
|
37
34
|
}
|
|
38
|
-
var languageId =
|
|
35
|
+
var languageId = parseUnicodeLanguageId(tag);
|
|
39
36
|
if (language !== undefined) {
|
|
40
37
|
languageId.lang = language;
|
|
41
38
|
}
|
|
@@ -45,12 +42,12 @@ function applyOptionsToTag(tag, options) {
|
|
|
45
42
|
if (region !== undefined) {
|
|
46
43
|
languageId.region = region;
|
|
47
44
|
}
|
|
48
|
-
return Intl.getCanonicalLocales(
|
|
45
|
+
return Intl.getCanonicalLocales(emitUnicodeLocaleId(__assign(__assign({}, parseUnicodeLocaleId(tag)), { lang: languageId })))[0];
|
|
49
46
|
}
|
|
50
47
|
function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
51
48
|
var unicodeExtension;
|
|
52
49
|
var keywords = [];
|
|
53
|
-
var ast =
|
|
50
|
+
var ast = parseUnicodeLocaleId(tag);
|
|
54
51
|
for (var _i = 0, _a = ast.extensions; _i < _a.length; _i++) {
|
|
55
52
|
var ext = _a[_i];
|
|
56
53
|
if (ext.type === 'u') {
|
|
@@ -70,10 +67,10 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
70
67
|
value = entry[1];
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
|
|
70
|
+
invariant(key in options, "".concat(key, " must be in options"));
|
|
74
71
|
var optionsValue = options[key];
|
|
75
72
|
if (optionsValue !== undefined) {
|
|
76
|
-
|
|
73
|
+
invariant(typeof optionsValue === 'string', "Value for ".concat(key, " must be a string"));
|
|
77
74
|
value = optionsValue;
|
|
78
75
|
if (entry) {
|
|
79
76
|
entry[1] = value;
|
|
@@ -96,7 +93,7 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
96
93
|
else {
|
|
97
94
|
unicodeExtension.keywords = keywords;
|
|
98
95
|
}
|
|
99
|
-
result.locale = Intl.getCanonicalLocales(
|
|
96
|
+
result.locale = Intl.getCanonicalLocales(emitUnicodeLocaleId(ast))[0];
|
|
100
97
|
return result;
|
|
101
98
|
}
|
|
102
99
|
function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
@@ -113,45 +110,45 @@ function mergeUnicodeLanguageId(lang, script, region, variants, replacement) {
|
|
|
113
110
|
lang: !lang || lang === 'und' ? replacement.lang : lang,
|
|
114
111
|
script: script || replacement.script,
|
|
115
112
|
region: region || replacement.region,
|
|
116
|
-
variants:
|
|
113
|
+
variants: __spreadArray(__spreadArray([], variants, true), replacement.variants, true),
|
|
117
114
|
};
|
|
118
115
|
}
|
|
119
116
|
function addLikelySubtags(tag) {
|
|
120
|
-
var ast =
|
|
117
|
+
var ast = parseUnicodeLocaleId(tag);
|
|
121
118
|
var unicodeLangId = ast.lang;
|
|
122
119
|
var lang = unicodeLangId.lang, script = unicodeLangId.script, region = unicodeLangId.region, variants = unicodeLangId.variants;
|
|
123
120
|
if (script && region) {
|
|
124
|
-
var match_1 =
|
|
121
|
+
var match_1 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, region: region, variants: [] })];
|
|
125
122
|
if (match_1) {
|
|
126
|
-
var parts_1 =
|
|
123
|
+
var parts_1 = parseUnicodeLanguageId(match_1);
|
|
127
124
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, undefined, variants, parts_1);
|
|
128
|
-
return
|
|
125
|
+
return emitUnicodeLocaleId(ast);
|
|
129
126
|
}
|
|
130
127
|
}
|
|
131
128
|
if (script) {
|
|
132
|
-
var match_2 =
|
|
129
|
+
var match_2 = likelySubtags[emitUnicodeLanguageId({ lang: lang, script: script, variants: [] })];
|
|
133
130
|
if (match_2) {
|
|
134
|
-
var parts_2 =
|
|
131
|
+
var parts_2 = parseUnicodeLanguageId(match_2);
|
|
135
132
|
ast.lang = mergeUnicodeLanguageId(undefined, undefined, region, variants, parts_2);
|
|
136
|
-
return
|
|
133
|
+
return emitUnicodeLocaleId(ast);
|
|
137
134
|
}
|
|
138
135
|
}
|
|
139
136
|
if (region) {
|
|
140
|
-
var match_3 =
|
|
137
|
+
var match_3 = likelySubtags[emitUnicodeLanguageId({ lang: lang, region: region, variants: [] })];
|
|
141
138
|
if (match_3) {
|
|
142
|
-
var parts_3 =
|
|
139
|
+
var parts_3 = parseUnicodeLanguageId(match_3);
|
|
143
140
|
ast.lang = mergeUnicodeLanguageId(undefined, script, undefined, variants, parts_3);
|
|
144
|
-
return
|
|
141
|
+
return emitUnicodeLocaleId(ast);
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
|
-
var match =
|
|
148
|
-
|
|
144
|
+
var match = likelySubtags[lang] ||
|
|
145
|
+
likelySubtags[emitUnicodeLanguageId({ lang: 'und', script: script, variants: [] })];
|
|
149
146
|
if (!match) {
|
|
150
147
|
throw new Error("No match for addLikelySubtags");
|
|
151
148
|
}
|
|
152
|
-
var parts =
|
|
149
|
+
var parts = parseUnicodeLanguageId(match);
|
|
153
150
|
ast.lang = mergeUnicodeLanguageId(undefined, script, region, variants, parts);
|
|
154
|
-
return
|
|
151
|
+
return emitUnicodeLocaleId(ast);
|
|
155
152
|
}
|
|
156
153
|
/**
|
|
157
154
|
* From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
|
|
@@ -162,23 +159,23 @@ function removeLikelySubtags(tag) {
|
|
|
162
159
|
if (!maxLocale) {
|
|
163
160
|
return tag;
|
|
164
161
|
}
|
|
165
|
-
maxLocale =
|
|
166
|
-
var ast =
|
|
162
|
+
maxLocale = emitUnicodeLanguageId(__assign(__assign({}, parseUnicodeLanguageId(maxLocale)), { variants: [] }));
|
|
163
|
+
var ast = parseUnicodeLocaleId(tag);
|
|
167
164
|
var _a = ast.lang, lang = _a.lang, script = _a.script, region = _a.region, variants = _a.variants;
|
|
168
|
-
var trial = addLikelySubtags(
|
|
165
|
+
var trial = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, variants: [] }));
|
|
169
166
|
if (trial === maxLocale) {
|
|
170
|
-
return
|
|
167
|
+
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, undefined, variants) }));
|
|
171
168
|
}
|
|
172
169
|
if (region) {
|
|
173
|
-
var trial_1 = addLikelySubtags(
|
|
170
|
+
var trial_1 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, region: region, variants: [] }));
|
|
174
171
|
if (trial_1 === maxLocale) {
|
|
175
|
-
return
|
|
172
|
+
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, undefined, region, variants) }));
|
|
176
173
|
}
|
|
177
174
|
}
|
|
178
175
|
if (script) {
|
|
179
|
-
var trial_2 = addLikelySubtags(
|
|
176
|
+
var trial_2 = addLikelySubtags(emitUnicodeLanguageId({ lang: lang, script: script, variants: [] }));
|
|
180
177
|
if (trial_2 === maxLocale) {
|
|
181
|
-
return
|
|
178
|
+
return emitUnicodeLocaleId(__assign(__assign({}, ast), { lang: mergeUnicodeLanguageId(lang, script, undefined, variants) }));
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
return tag;
|
|
@@ -191,55 +188,55 @@ function createArrayFromListOrRestricted(list, restricted) {
|
|
|
191
188
|
return Array.from(result);
|
|
192
189
|
}
|
|
193
190
|
function calendarsOfLocale(loc) {
|
|
194
|
-
var locInternalSlots = (
|
|
191
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
195
192
|
var restricted = locInternalSlots.calendar;
|
|
196
193
|
var locale = locInternalSlots.locale;
|
|
197
194
|
var region;
|
|
198
195
|
if (locale !== 'root') {
|
|
199
196
|
region = loc.maximize().region;
|
|
200
197
|
}
|
|
201
|
-
var preferredCalendars =
|
|
198
|
+
var preferredCalendars = getCalendarPreferenceDataForRegion(region);
|
|
202
199
|
return createArrayFromListOrRestricted(preferredCalendars, restricted);
|
|
203
200
|
}
|
|
204
201
|
function collationsOfLocale(loc) {
|
|
205
|
-
var locInternalSlots = (
|
|
202
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
206
203
|
var restricted = locInternalSlots.collation;
|
|
207
204
|
var locale = locInternalSlots.locale;
|
|
208
|
-
var supportedCollations =
|
|
205
|
+
var supportedCollations = supportedValuesOf('collation', locale).filter(function (co) { return co !== 'standard' && co !== 'search'; });
|
|
209
206
|
supportedCollations.sort();
|
|
210
207
|
return createArrayFromListOrRestricted(supportedCollations, restricted);
|
|
211
208
|
}
|
|
212
209
|
function hourCyclesOfLocale(loc) {
|
|
213
|
-
var locInternalSlots = (
|
|
210
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
214
211
|
var restricted = locInternalSlots.hourCycle;
|
|
215
212
|
var locale = locInternalSlots.locale;
|
|
216
213
|
var region;
|
|
217
214
|
if (locale !== 'root') {
|
|
218
215
|
region = loc.maximize().region;
|
|
219
216
|
}
|
|
220
|
-
var preferredHourCycles =
|
|
217
|
+
var preferredHourCycles = getHourCyclesPreferenceDataForLocaleOrRegion(locale, region);
|
|
221
218
|
return createArrayFromListOrRestricted(preferredHourCycles, restricted);
|
|
222
219
|
}
|
|
223
220
|
function numberingSystemsOfLocale(loc) {
|
|
224
221
|
var _a;
|
|
225
|
-
var locInternalSlots = (
|
|
222
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
226
223
|
var restricted = locInternalSlots.numberingSystem;
|
|
227
224
|
var locale = locInternalSlots.locale;
|
|
228
225
|
var language = loc.language;
|
|
229
|
-
var localeNumberingSystems = (_a =
|
|
226
|
+
var localeNumberingSystems = (_a = numberingSystems[locale]) !== null && _a !== void 0 ? _a : numberingSystems[language];
|
|
230
227
|
if (localeNumberingSystems) {
|
|
231
|
-
return createArrayFromListOrRestricted(
|
|
228
|
+
return createArrayFromListOrRestricted(__spreadArray([], localeNumberingSystems, true), restricted);
|
|
232
229
|
}
|
|
233
230
|
return createArrayFromListOrRestricted([], restricted);
|
|
234
231
|
}
|
|
235
232
|
function timeZonesOfLocale(loc) {
|
|
236
|
-
var locInternalSlots = (
|
|
233
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
237
234
|
var locale = locInternalSlots.locale;
|
|
238
|
-
var region =
|
|
235
|
+
var region = parseUnicodeLanguageId(locale).region;
|
|
239
236
|
if (!region) {
|
|
240
237
|
return undefined;
|
|
241
238
|
}
|
|
242
|
-
var preferredTimeZones =
|
|
239
|
+
var preferredTimeZones = getTimeZonePreferenceForRegion(region);
|
|
243
240
|
preferredTimeZones.sort();
|
|
244
241
|
return Array.from(preferredTimeZones);
|
|
245
242
|
}
|
|
@@ -251,16 +248,16 @@ function translateCharacterOrder(order) {
|
|
|
251
248
|
}
|
|
252
249
|
function characterDirectionOfLocale(loc) {
|
|
253
250
|
var locale = loc.minimize().toString();
|
|
254
|
-
return translateCharacterOrder(
|
|
251
|
+
return translateCharacterOrder(characterOrders[locale]);
|
|
255
252
|
}
|
|
256
253
|
function weekInfoOfLocale(loc) {
|
|
257
|
-
var locInternalSlots = (
|
|
254
|
+
var locInternalSlots = getInternalSlots(loc);
|
|
258
255
|
var locale = locInternalSlots.locale;
|
|
259
256
|
var region;
|
|
260
257
|
if (locale !== 'root') {
|
|
261
258
|
region = loc.maximize().region;
|
|
262
259
|
}
|
|
263
|
-
return
|
|
260
|
+
return getWeekDataForRegion(region);
|
|
264
261
|
}
|
|
265
262
|
var TABLE_1 = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
|
266
263
|
function weekdayToString(fw) {
|
|
@@ -297,32 +294,32 @@ var Locale = /** @class */ (function () {
|
|
|
297
294
|
}
|
|
298
295
|
var tagInternalSlots;
|
|
299
296
|
if (typeof tag === 'object' &&
|
|
300
|
-
(tagInternalSlots = (
|
|
301
|
-
|
|
297
|
+
(tagInternalSlots = getInternalSlots(tag)) &&
|
|
298
|
+
HasOwnProperty(tagInternalSlots, 'initializedLocale')) {
|
|
302
299
|
tag = tagInternalSlots.locale;
|
|
303
300
|
}
|
|
304
301
|
else {
|
|
305
302
|
tag = tag.toString();
|
|
306
303
|
}
|
|
307
|
-
var internalSlots = (
|
|
308
|
-
var options =
|
|
304
|
+
var internalSlots = getInternalSlots(this, internalSlotsList);
|
|
305
|
+
var options = CoerceOptionsToObject(opts);
|
|
309
306
|
tag = applyOptionsToTag(tag, options);
|
|
310
307
|
var opt = Object.create(null);
|
|
311
|
-
var calendar =
|
|
308
|
+
var calendar = GetOption(options, 'calendar', 'string', undefined, undefined);
|
|
312
309
|
if (calendar !== undefined) {
|
|
313
310
|
if (!UNICODE_TYPE_REGEX.test(calendar)) {
|
|
314
311
|
throw new RangeError('invalid calendar');
|
|
315
312
|
}
|
|
316
313
|
}
|
|
317
314
|
opt.ca = calendar;
|
|
318
|
-
var collation =
|
|
315
|
+
var collation = GetOption(options, 'collation', 'string', undefined, undefined);
|
|
319
316
|
if (collation !== undefined) {
|
|
320
317
|
if (!UNICODE_TYPE_REGEX.test(collation)) {
|
|
321
318
|
throw new RangeError('invalid collation');
|
|
322
319
|
}
|
|
323
320
|
}
|
|
324
321
|
opt.co = collation;
|
|
325
|
-
var fw =
|
|
322
|
+
var fw = GetOption(options, 'firstDayOfWeek', 'string', undefined, undefined);
|
|
326
323
|
if (fw !== undefined) {
|
|
327
324
|
fw = weekdayToString(fw);
|
|
328
325
|
if (!ALPHANUM_3_8.test(fw)) {
|
|
@@ -330,17 +327,17 @@ var Locale = /** @class */ (function () {
|
|
|
330
327
|
}
|
|
331
328
|
}
|
|
332
329
|
opt.fw = fw;
|
|
333
|
-
var hc =
|
|
330
|
+
var hc = GetOption(options, 'hourCycle', 'string', ['h11', 'h12', 'h23', 'h24'], undefined);
|
|
334
331
|
opt.hc = hc;
|
|
335
|
-
var kf =
|
|
332
|
+
var kf = GetOption(options, 'caseFirst', 'string', ['upper', 'lower', 'false'], undefined);
|
|
336
333
|
opt.kf = kf;
|
|
337
|
-
var _kn =
|
|
334
|
+
var _kn = GetOption(options, 'numeric', 'boolean', undefined, undefined);
|
|
338
335
|
var kn;
|
|
339
336
|
if (_kn !== undefined) {
|
|
340
337
|
kn = String(_kn);
|
|
341
338
|
}
|
|
342
339
|
opt.kn = kn;
|
|
343
|
-
var numberingSystem =
|
|
340
|
+
var numberingSystem = GetOption(options, 'numberingSystem', 'string', undefined, undefined);
|
|
344
341
|
if (numberingSystem !== undefined) {
|
|
345
342
|
if (!UNICODE_TYPE_REGEX.test(numberingSystem)) {
|
|
346
343
|
throw new RangeError('Invalid numberingSystem');
|
|
@@ -357,7 +354,7 @@ var Locale = /** @class */ (function () {
|
|
|
357
354
|
internalSlots.caseFirst = r.kf;
|
|
358
355
|
}
|
|
359
356
|
if (relevantExtensionKeys.indexOf('kn') > -1) {
|
|
360
|
-
internalSlots.numeric =
|
|
357
|
+
internalSlots.numeric = SameValue(r.kn, 'true');
|
|
361
358
|
}
|
|
362
359
|
internalSlots.numberingSystem = r.nu;
|
|
363
360
|
}
|
|
@@ -365,12 +362,12 @@ var Locale = /** @class */ (function () {
|
|
|
365
362
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
366
363
|
*/
|
|
367
364
|
Locale.prototype.maximize = function () {
|
|
368
|
-
var locale = (
|
|
365
|
+
var locale = getInternalSlots(this).locale;
|
|
369
366
|
try {
|
|
370
367
|
var maximizedLocale = addLikelySubtags(locale);
|
|
371
368
|
return new Locale(maximizedLocale);
|
|
372
369
|
}
|
|
373
|
-
catch (
|
|
370
|
+
catch (_a) {
|
|
374
371
|
return new Locale(locale);
|
|
375
372
|
}
|
|
376
373
|
};
|
|
@@ -378,57 +375,57 @@ var Locale = /** @class */ (function () {
|
|
|
378
375
|
* https://www.unicode.org/reports/tr35/#Likely_Subtags
|
|
379
376
|
*/
|
|
380
377
|
Locale.prototype.minimize = function () {
|
|
381
|
-
var locale = (
|
|
378
|
+
var locale = getInternalSlots(this).locale;
|
|
382
379
|
try {
|
|
383
380
|
var minimizedLocale = removeLikelySubtags(locale);
|
|
384
381
|
return new Locale(minimizedLocale);
|
|
385
382
|
}
|
|
386
|
-
catch (
|
|
383
|
+
catch (_a) {
|
|
387
384
|
return new Locale(locale);
|
|
388
385
|
}
|
|
389
386
|
};
|
|
390
387
|
Locale.prototype.toString = function () {
|
|
391
|
-
return (
|
|
388
|
+
return getInternalSlots(this).locale;
|
|
392
389
|
};
|
|
393
390
|
Object.defineProperty(Locale.prototype, "baseName", {
|
|
394
391
|
get: function () {
|
|
395
|
-
var locale = (
|
|
396
|
-
return
|
|
392
|
+
var locale = getInternalSlots(this).locale;
|
|
393
|
+
return emitUnicodeLanguageId(parseUnicodeLanguageId(locale));
|
|
397
394
|
},
|
|
398
395
|
enumerable: false,
|
|
399
396
|
configurable: true
|
|
400
397
|
});
|
|
401
398
|
Object.defineProperty(Locale.prototype, "calendar", {
|
|
402
399
|
get: function () {
|
|
403
|
-
return (
|
|
400
|
+
return getInternalSlots(this).calendar;
|
|
404
401
|
},
|
|
405
402
|
enumerable: false,
|
|
406
403
|
configurable: true
|
|
407
404
|
});
|
|
408
405
|
Object.defineProperty(Locale.prototype, "collation", {
|
|
409
406
|
get: function () {
|
|
410
|
-
return (
|
|
407
|
+
return getInternalSlots(this).collation;
|
|
411
408
|
},
|
|
412
409
|
enumerable: false,
|
|
413
410
|
configurable: true
|
|
414
411
|
});
|
|
415
412
|
Object.defineProperty(Locale.prototype, "caseFirst", {
|
|
416
413
|
get: function () {
|
|
417
|
-
return (
|
|
414
|
+
return getInternalSlots(this).caseFirst;
|
|
418
415
|
},
|
|
419
416
|
enumerable: false,
|
|
420
417
|
configurable: true
|
|
421
418
|
});
|
|
422
419
|
Object.defineProperty(Locale.prototype, "numeric", {
|
|
423
420
|
get: function () {
|
|
424
|
-
return (
|
|
421
|
+
return getInternalSlots(this).numeric;
|
|
425
422
|
},
|
|
426
423
|
enumerable: false,
|
|
427
424
|
configurable: true
|
|
428
425
|
});
|
|
429
426
|
Object.defineProperty(Locale.prototype, "numberingSystem", {
|
|
430
427
|
get: function () {
|
|
431
|
-
return (
|
|
428
|
+
return getInternalSlots(this).numberingSystem;
|
|
432
429
|
},
|
|
433
430
|
enumerable: false,
|
|
434
431
|
configurable: true
|
|
@@ -438,8 +435,8 @@ var Locale = /** @class */ (function () {
|
|
|
438
435
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.language
|
|
439
436
|
*/
|
|
440
437
|
get: function () {
|
|
441
|
-
var locale = (
|
|
442
|
-
return
|
|
438
|
+
var locale = getInternalSlots(this).locale;
|
|
439
|
+
return parseUnicodeLanguageId(locale).lang;
|
|
443
440
|
},
|
|
444
441
|
enumerable: false,
|
|
445
442
|
configurable: true
|
|
@@ -449,8 +446,8 @@ var Locale = /** @class */ (function () {
|
|
|
449
446
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.script
|
|
450
447
|
*/
|
|
451
448
|
get: function () {
|
|
452
|
-
var locale = (
|
|
453
|
-
return
|
|
449
|
+
var locale = getInternalSlots(this).locale;
|
|
450
|
+
return parseUnicodeLanguageId(locale).script;
|
|
454
451
|
},
|
|
455
452
|
enumerable: false,
|
|
456
453
|
configurable: true
|
|
@@ -460,16 +457,16 @@ var Locale = /** @class */ (function () {
|
|
|
460
457
|
* https://tc39.es/proposal-intl-locale/#sec-Intl.Locale.prototype.region
|
|
461
458
|
*/
|
|
462
459
|
get: function () {
|
|
463
|
-
var locale = (
|
|
464
|
-
return
|
|
460
|
+
var locale = getInternalSlots(this).locale;
|
|
461
|
+
return parseUnicodeLanguageId(locale).region;
|
|
465
462
|
},
|
|
466
463
|
enumerable: false,
|
|
467
464
|
configurable: true
|
|
468
465
|
});
|
|
469
466
|
Object.defineProperty(Locale.prototype, "firstDayOfWeek", {
|
|
470
467
|
get: function () {
|
|
471
|
-
var internalSlots = (
|
|
472
|
-
if (!
|
|
468
|
+
var internalSlots = getInternalSlots(this);
|
|
469
|
+
if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
|
|
473
470
|
throw new TypeError('Error uninitialized locale');
|
|
474
471
|
}
|
|
475
472
|
return internalSlots.firstDayOfWeek;
|
|
@@ -479,8 +476,8 @@ var Locale = /** @class */ (function () {
|
|
|
479
476
|
});
|
|
480
477
|
Object.defineProperty(Locale.prototype, "hourCycle", {
|
|
481
478
|
get: function () {
|
|
482
|
-
var internalSlots = (
|
|
483
|
-
if (!
|
|
479
|
+
var internalSlots = getInternalSlots(this);
|
|
480
|
+
if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
|
|
484
481
|
throw new TypeError('Error uninitialized locale');
|
|
485
482
|
}
|
|
486
483
|
return internalSlots.hourCycle;
|
|
@@ -507,8 +504,8 @@ var Locale = /** @class */ (function () {
|
|
|
507
504
|
* https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
|
|
508
505
|
*/
|
|
509
506
|
Locale.prototype.getHourCycles = function () {
|
|
510
|
-
var internalSlots = (
|
|
511
|
-
if (!
|
|
507
|
+
var internalSlots = getInternalSlots(this);
|
|
508
|
+
if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
|
|
512
509
|
throw new TypeError('Error uninitialized locale');
|
|
513
510
|
}
|
|
514
511
|
return hourCyclesOfLocale(this);
|
|
@@ -534,7 +531,7 @@ var Locale = /** @class */ (function () {
|
|
|
534
531
|
Locale.prototype.getTextInfo = function () {
|
|
535
532
|
var info = Object.create(Object.prototype);
|
|
536
533
|
var dir = characterDirectionOfLocale(this);
|
|
537
|
-
|
|
534
|
+
createDataProperty(info, 'direction', dir);
|
|
538
535
|
return info;
|
|
539
536
|
};
|
|
540
537
|
/**
|
|
@@ -543,15 +540,15 @@ var Locale = /** @class */ (function () {
|
|
|
543
540
|
*/
|
|
544
541
|
Locale.prototype.getWeekInfo = function () {
|
|
545
542
|
var info = Object.create(Object.prototype);
|
|
546
|
-
var internalSlots = (
|
|
547
|
-
if (!
|
|
543
|
+
var internalSlots = getInternalSlots(this);
|
|
544
|
+
if (!HasOwnProperty(internalSlots, 'initializedLocale')) {
|
|
548
545
|
throw new TypeError('Error uninitialized locale');
|
|
549
546
|
}
|
|
550
547
|
var wi = weekInfoOfLocale(this);
|
|
551
548
|
var we = wi.weekend;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
549
|
+
createDataProperty(info, 'firstDay', wi.firstDay);
|
|
550
|
+
createDataProperty(info, 'weekend', we);
|
|
551
|
+
createDataProperty(info, 'minimalDays', wi.minimalDays);
|
|
555
552
|
var fw = internalSlots.firstDayOfWeek;
|
|
556
553
|
if (fw !== undefined) {
|
|
557
554
|
info.firstDay = fw;
|
|
@@ -562,7 +559,7 @@ var Locale = /** @class */ (function () {
|
|
|
562
559
|
Locale.polyfilled = true;
|
|
563
560
|
return Locale;
|
|
564
561
|
}());
|
|
565
|
-
|
|
562
|
+
export { Locale };
|
|
566
563
|
try {
|
|
567
564
|
if (typeof Symbol !== 'undefined') {
|
|
568
565
|
Object.defineProperty(Locale.prototype, Symbol.toStringTag, {
|
|
@@ -579,7 +576,7 @@ try {
|
|
|
579
576
|
configurable: true,
|
|
580
577
|
});
|
|
581
578
|
}
|
|
582
|
-
catch (
|
|
579
|
+
catch (_a) {
|
|
583
580
|
// Meta fix so we're test262-compliant, not important
|
|
584
581
|
}
|
|
585
|
-
|
|
582
|
+
export default Locale;
|
package/package.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-locale",
|
|
3
3
|
"description": "Intl.Locale polyfill",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js",
|
|
11
|
+
"./polyfill.js": "./polyfill.js",
|
|
12
|
+
"./polyfill-force.js": "./polyfill-force.js",
|
|
13
|
+
"./should-polyfill.js": "./should-polyfill.js"
|
|
14
|
+
},
|
|
8
15
|
"dependencies": {
|
|
9
16
|
"tslib": "^2.8.0",
|
|
10
|
-
"@formatjs/ecma402-abstract": "
|
|
11
|
-
"@formatjs/intl-enumerator": "
|
|
12
|
-
"@formatjs/intl-getcanonicallocales": "
|
|
17
|
+
"@formatjs/ecma402-abstract": "3.0.1",
|
|
18
|
+
"@formatjs/intl-enumerator": "2.0.1",
|
|
19
|
+
"@formatjs/intl-getcanonicallocales": "3.0.1"
|
|
13
20
|
},
|
|
14
21
|
"bugs": "https://github.com/formatjs/formatjs/issues",
|
|
15
22
|
"homepage": "https://github.com/formatjs/formatjs#readme",
|
|
@@ -22,6 +29,5 @@
|
|
|
22
29
|
"react-intl",
|
|
23
30
|
"tc39"
|
|
24
31
|
],
|
|
25
|
-
"main": "index.js",
|
|
26
32
|
"repository": "formatjs/formatjs.git"
|
|
27
33
|
}
|
package/polyfill-force.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var _1 = require("./");
|
|
1
|
+
import { Locale } from './index.js';
|
|
4
2
|
Object.defineProperty(Intl, 'Locale', {
|
|
5
|
-
value:
|
|
3
|
+
value: Locale,
|
|
6
4
|
writable: true,
|
|
7
5
|
enumerable: false,
|
|
8
6
|
configurable: true,
|