@formatjs/intl-locale 5.3.9 → 5.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +48 -49
- package/index.js +126 -89
- package/index.js.map +1 -1
- package/package.json +7 -4
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +126 -91
- package/polyfill-force.js.map +1 -1
- package/polyfill.d.ts +1 -1
- package/polyfill.iife.js +811 -154
- package/polyfill.js +126 -89
- package/polyfill.js.map +1 -1
- package/should-polyfill.d.ts +1 -2
- package/should-polyfill.js.map +1 -1
package/polyfill.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { supportedValuesOf } from "@formatjs/intl-supportedvaluesof";
|
|
2
|
-
import { emitUnicodeLanguageId, emitUnicodeLocaleId, isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, likelySubtags, parseUnicodeLanguageId, parseUnicodeLocaleId } from "@formatjs/intl-getcanonicallocales";
|
|
2
|
+
import { emitUnicodeLanguageId, emitUnicodeLocaleId, isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, isUnicodeVariantSubtag, likelySubtags, parseUnicodeLanguageId, parseUnicodeLocaleId } from "@formatjs/intl-getcanonicallocales";
|
|
3
|
+
//#region packages/ecma262-abstract/ToString.js
|
|
4
|
+
/**
|
|
5
|
+
* https://tc39.es/ecma262/#sec-tostring
|
|
6
|
+
*/
|
|
7
|
+
function ToString(o) {
|
|
8
|
+
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
|
|
9
|
+
return String(o);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
|
|
13
|
+
/** Tests the Unicode locale identifier `type` grammar, not locale support. */
|
|
14
|
+
function IsUnicodeLocaleIdentifierType(value) {
|
|
15
|
+
return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
3
18
|
//#region packages/ecma262-abstract/HasOwnProperty.js
|
|
4
19
|
/**
|
|
5
20
|
* https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
|
|
@@ -38,15 +53,6 @@ function CoerceOptionsToObject(options) {
|
|
|
38
53
|
return ToObject(options);
|
|
39
54
|
}
|
|
40
55
|
//#endregion
|
|
41
|
-
//#region packages/ecma262-abstract/ToString.js
|
|
42
|
-
/**
|
|
43
|
-
* https://tc39.es/ecma262/#sec-tostring
|
|
44
|
-
*/
|
|
45
|
-
function ToString(o) {
|
|
46
|
-
if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
|
|
47
|
-
return String(o);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
56
|
//#region packages/ecma402-abstract/GetOption.js
|
|
51
57
|
/**
|
|
52
58
|
* https://tc39.es/ecma402/#sec-getoption
|
|
@@ -57,7 +63,7 @@ function ToString(o) {
|
|
|
57
63
|
* @param fallback
|
|
58
64
|
*/
|
|
59
65
|
function GetOption(opts, prop, type, values, fallback) {
|
|
60
|
-
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
66
|
+
if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
|
|
61
67
|
let value = opts[prop];
|
|
62
68
|
if (value !== void 0) {
|
|
63
69
|
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
@@ -946,9 +952,13 @@ const characterOrders = {
|
|
|
946
952
|
//#endregion
|
|
947
953
|
//#region packages/intl-locale/get_internal_slots.ts
|
|
948
954
|
const internalSlotMap = /* @__PURE__ */ new WeakMap();
|
|
949
|
-
function
|
|
955
|
+
function getInternalSlotsIfPresent(x) {
|
|
956
|
+
return internalSlotMap.get(x);
|
|
957
|
+
}
|
|
958
|
+
function getInternalSlots(x, internalSlotsList) {
|
|
950
959
|
let internalSlots = internalSlotMap.get(x);
|
|
951
960
|
if (!internalSlots) {
|
|
961
|
+
if (internalSlotsList === void 0) throw new TypeError("Intl.Locale method called on incompatible receiver");
|
|
952
962
|
internalSlots = Object.create(null, internalSlotsList.reduce((all, prop) => {
|
|
953
963
|
all[prop] = {
|
|
954
964
|
enumerable: false,
|
|
@@ -4179,29 +4189,36 @@ const weekData = {
|
|
|
4179
4189
|
};
|
|
4180
4190
|
//#endregion
|
|
4181
4191
|
//#region packages/intl-locale/preference-data.ts
|
|
4182
|
-
function getCalendarPreferenceDataForRegion(region) {
|
|
4183
|
-
|
|
4184
|
-
if (
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4192
|
+
function getCalendarPreferenceDataForRegion(region, regionOverride, language) {
|
|
4193
|
+
for (const candidate of [regionOverride, region]) {
|
|
4194
|
+
if (!candidate) continue;
|
|
4195
|
+
const territory = candidate.toUpperCase();
|
|
4196
|
+
const values = calendars[`${language}-${territory}`] || calendars[territory];
|
|
4197
|
+
if (values) return values.map((c) => c === "gregorian" ? "gregory" : c);
|
|
4198
|
+
}
|
|
4199
|
+
return ["gregory"];
|
|
4188
4200
|
}
|
|
4189
|
-
function getHourCyclesPreferenceDataForLocaleOrRegion(
|
|
4190
|
-
const
|
|
4191
|
-
|
|
4192
|
-
|
|
4201
|
+
function getHourCyclesPreferenceDataForLocaleOrRegion(language, region, regionOverride) {
|
|
4202
|
+
for (const candidate of [regionOverride, region]) {
|
|
4203
|
+
if (!candidate) continue;
|
|
4204
|
+
const territory = candidate.toUpperCase();
|
|
4205
|
+
const values = hourCycles[`${language}-${territory}`] || hourCycles[territory];
|
|
4206
|
+
if (values) return [...values];
|
|
4207
|
+
}
|
|
4208
|
+
return ["h23"];
|
|
4193
4209
|
}
|
|
4194
4210
|
function getTimeZonePreferenceForRegion(region) {
|
|
4195
4211
|
const territory = region.toLowerCase();
|
|
4196
4212
|
if (timezones[territory]) return [...timezones[territory]];
|
|
4197
4213
|
return [];
|
|
4198
4214
|
}
|
|
4199
|
-
function getWeekDataForRegion(region) {
|
|
4200
|
-
|
|
4215
|
+
function getWeekDataForRegion(region, regionOverride) {
|
|
4216
|
+
const _region = region ? region.toUpperCase() : "";
|
|
4217
|
+
const override = (regionOverride || "").toUpperCase();
|
|
4218
|
+
return weekData[override] || weekData[_region] || weekData["001"];
|
|
4201
4219
|
}
|
|
4202
4220
|
//#endregion
|
|
4203
4221
|
//#region packages/intl-locale/index.ts
|
|
4204
|
-
const ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
|
|
4205
4222
|
const RELEVANT_EXTENSION_KEYS = [
|
|
4206
4223
|
"ca",
|
|
4207
4224
|
"co",
|
|
@@ -4211,17 +4228,23 @@ const RELEVANT_EXTENSION_KEYS = [
|
|
|
4211
4228
|
"nu",
|
|
4212
4229
|
"fw"
|
|
4213
4230
|
];
|
|
4214
|
-
const UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
|
|
4215
4231
|
function applyOptionsToTag(tag, options) {
|
|
4216
4232
|
invariant(typeof tag === "string", "language tag must be a string");
|
|
4217
4233
|
invariant(isStructurallyValidLanguageTag(tag), "malformed language tag", RangeError);
|
|
4234
|
+
tag = Intl.getCanonicalLocales(tag)[0];
|
|
4218
4235
|
const language = GetOption(options, "language", "string", void 0, void 0);
|
|
4219
4236
|
if (language !== void 0) invariant(isUnicodeLanguageSubtag(language), "Malformed unicode_language_subtag", RangeError);
|
|
4220
4237
|
const script = GetOption(options, "script", "string", void 0, void 0);
|
|
4221
4238
|
if (script !== void 0) invariant(isUnicodeScriptSubtag(script), "Malformed unicode_script_subtag", RangeError);
|
|
4222
4239
|
const region = GetOption(options, "region", "string", void 0, void 0);
|
|
4223
4240
|
if (region !== void 0) invariant(isUnicodeRegionSubtag(region), "Malformed unicode_region_subtag", RangeError);
|
|
4241
|
+
const variants = GetOption(options, "variants", "string", void 0, void 0);
|
|
4224
4242
|
const languageId = parseUnicodeLanguageId(tag);
|
|
4243
|
+
if (variants !== void 0) {
|
|
4244
|
+
const subtags = variants.replace(/[A-Z]/g, (character) => character.toLowerCase()).split("-");
|
|
4245
|
+
if (subtags.some((variant) => !isUnicodeVariantSubtag(variant)) || new Set(subtags).size !== subtags.length) throw new RangeError("Malformed unicode_variant_subtag");
|
|
4246
|
+
languageId.variants = subtags;
|
|
4247
|
+
}
|
|
4225
4248
|
if (language !== void 0) languageId.lang = language;
|
|
4226
4249
|
if (script !== void 0) languageId.script = script;
|
|
4227
4250
|
if (region !== void 0) languageId.region = region;
|
|
@@ -4263,6 +4286,8 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
|
|
|
4263
4286
|
});
|
|
4264
4287
|
} else unicodeExtension.keywords = keywords;
|
|
4265
4288
|
result.locale = Intl.getCanonicalLocales(emitUnicodeLocaleId(ast))[0];
|
|
4289
|
+
const canonicalExtension = parseUnicodeLocaleId(result.locale).extensions.find((extension) => extension.type === "u");
|
|
4290
|
+
for (const key of relevantExtensionKeys) result[key] = canonicalExtension?.keywords.find((keyword) => keyword[0] === key)?.[1];
|
|
4266
4291
|
return result;
|
|
4267
4292
|
}
|
|
4268
4293
|
function mergeUnicodeLanguageId(lang, script, region, variants = [], replacement) {
|
|
@@ -4281,49 +4306,38 @@ function mergeUnicodeLanguageId(lang, script, region, variants = [], replacement
|
|
|
4281
4306
|
}
|
|
4282
4307
|
function addLikelySubtags(tag) {
|
|
4283
4308
|
const ast = parseUnicodeLocaleId(tag);
|
|
4284
|
-
const { lang,
|
|
4285
|
-
|
|
4286
|
-
|
|
4309
|
+
const { lang, variants } = ast.lang;
|
|
4310
|
+
const script = ast.lang.script === "Zzzz" ? void 0 : ast.lang.script;
|
|
4311
|
+
const region = ast.lang.region === "ZZ" ? void 0 : ast.lang.region;
|
|
4312
|
+
if (lang !== "und" && script && region) return tag;
|
|
4313
|
+
for (const candidate of [
|
|
4314
|
+
{
|
|
4287
4315
|
lang,
|
|
4288
4316
|
script,
|
|
4289
4317
|
region,
|
|
4290
4318
|
variants: []
|
|
4291
|
-
}
|
|
4292
|
-
|
|
4293
|
-
ast.lang = mergeUnicodeLanguageId(void 0, void 0, void 0, variants, parseUnicodeLanguageId(match));
|
|
4294
|
-
return emitUnicodeLocaleId(ast);
|
|
4295
|
-
}
|
|
4296
|
-
}
|
|
4297
|
-
if (script) {
|
|
4298
|
-
const match = likelySubtags[emitUnicodeLanguageId({
|
|
4319
|
+
},
|
|
4320
|
+
{
|
|
4299
4321
|
lang,
|
|
4300
4322
|
script,
|
|
4301
4323
|
variants: []
|
|
4302
|
-
}
|
|
4303
|
-
|
|
4304
|
-
ast.lang = mergeUnicodeLanguageId(void 0, void 0, region, variants, parseUnicodeLanguageId(match));
|
|
4305
|
-
return emitUnicodeLocaleId(ast);
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
if (region) {
|
|
4309
|
-
const match = likelySubtags[emitUnicodeLanguageId({
|
|
4324
|
+
},
|
|
4325
|
+
{
|
|
4310
4326
|
lang,
|
|
4311
4327
|
region,
|
|
4312
4328
|
variants: []
|
|
4313
|
-
}
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4329
|
+
},
|
|
4330
|
+
{
|
|
4331
|
+
lang,
|
|
4332
|
+
variants: []
|
|
4317
4333
|
}
|
|
4334
|
+
]) {
|
|
4335
|
+
const match = likelySubtags[emitUnicodeLanguageId(candidate)];
|
|
4336
|
+
if (!match) continue;
|
|
4337
|
+
ast.lang = mergeUnicodeLanguageId(lang, script, region, variants, parseUnicodeLanguageId(match));
|
|
4338
|
+
return emitUnicodeLocaleId(ast);
|
|
4318
4339
|
}
|
|
4319
|
-
|
|
4320
|
-
lang: "und",
|
|
4321
|
-
script,
|
|
4322
|
-
variants: []
|
|
4323
|
-
})];
|
|
4324
|
-
if (!match) throw new Error(`No match for addLikelySubtags`);
|
|
4325
|
-
ast.lang = mergeUnicodeLanguageId(void 0, script, region, variants, parseUnicodeLanguageId(match));
|
|
4326
|
-
return emitUnicodeLocaleId(ast);
|
|
4340
|
+
return tag;
|
|
4327
4341
|
}
|
|
4328
4342
|
/**
|
|
4329
4343
|
* From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
|
|
@@ -4332,11 +4346,11 @@ function addLikelySubtags(tag) {
|
|
|
4332
4346
|
function removeLikelySubtags(tag) {
|
|
4333
4347
|
let maxLocale = addLikelySubtags(tag);
|
|
4334
4348
|
if (!maxLocale) return tag;
|
|
4349
|
+
const ast = parseUnicodeLocaleId(maxLocale);
|
|
4335
4350
|
maxLocale = emitUnicodeLanguageId({
|
|
4336
4351
|
...parseUnicodeLanguageId(maxLocale),
|
|
4337
4352
|
variants: []
|
|
4338
4353
|
});
|
|
4339
|
-
const ast = parseUnicodeLocaleId(tag);
|
|
4340
4354
|
const { lang: { lang, script, region, variants } } = ast;
|
|
4341
4355
|
if (addLikelySubtags(emitUnicodeLanguageId({
|
|
4342
4356
|
lang,
|
|
@@ -4365,7 +4379,7 @@ function removeLikelySubtags(tag) {
|
|
|
4365
4379
|
lang: mergeUnicodeLanguageId(lang, script, void 0, variants)
|
|
4366
4380
|
});
|
|
4367
4381
|
}
|
|
4368
|
-
return
|
|
4382
|
+
return emitUnicodeLocaleId(ast);
|
|
4369
4383
|
}
|
|
4370
4384
|
function createArrayFromListOrRestricted(list, restricted) {
|
|
4371
4385
|
let result = list;
|
|
@@ -4376,13 +4390,19 @@ function calendarsOfLocale(loc) {
|
|
|
4376
4390
|
const locInternalSlots = getInternalSlots(loc);
|
|
4377
4391
|
const restricted = locInternalSlots.calendar;
|
|
4378
4392
|
const locale = locInternalSlots.locale;
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
return createArrayFromListOrRestricted(getCalendarPreferenceDataForRegion(region), restricted);
|
|
4393
|
+
const { region, regionOverride } = regionPreference(loc);
|
|
4394
|
+
return createArrayFromListOrRestricted(getCalendarPreferenceDataForRegion(region, regionOverride, parseUnicodeLanguageId(locale).lang), restricted);
|
|
4382
4395
|
}
|
|
4383
4396
|
function collationsOfLocale(loc) {
|
|
4384
|
-
const
|
|
4385
|
-
const
|
|
4397
|
+
const locInternalSlots = getInternalSlots(loc);
|
|
4398
|
+
const restricted = locInternalSlots.collation;
|
|
4399
|
+
if (restricted !== void 0) return [restricted];
|
|
4400
|
+
const locale = locInternalSlots.locale;
|
|
4401
|
+
if (!Intl.Collator.supportedLocalesOf([locale], { localeMatcher: "lookup" }).length) return ["emoji", "eor"];
|
|
4402
|
+
const supportedCollations = supportedValuesOf("collation").filter((co) => co !== "standard" && co !== "search" && new Intl.Collator(locale, {
|
|
4403
|
+
collation: co,
|
|
4404
|
+
localeMatcher: "lookup"
|
|
4405
|
+
}).resolvedOptions().collation === co);
|
|
4386
4406
|
supportedCollations.sort();
|
|
4387
4407
|
return createArrayFromListOrRestricted(supportedCollations, restricted);
|
|
4388
4408
|
}
|
|
@@ -4390,9 +4410,8 @@ function hourCyclesOfLocale(loc) {
|
|
|
4390
4410
|
const locInternalSlots = getInternalSlots(loc);
|
|
4391
4411
|
const restricted = locInternalSlots.hourCycle;
|
|
4392
4412
|
const locale = locInternalSlots.locale;
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
return createArrayFromListOrRestricted(getHourCyclesPreferenceDataForLocaleOrRegion(locale, region), restricted);
|
|
4413
|
+
const { region, regionOverride } = regionPreference(loc);
|
|
4414
|
+
return createArrayFromListOrRestricted(getHourCyclesPreferenceDataForLocaleOrRegion(parseUnicodeLanguageId(locale).lang, region, regionOverride), restricted);
|
|
4396
4415
|
}
|
|
4397
4416
|
function numberingSystemsOfLocale(loc) {
|
|
4398
4417
|
const locInternalSlots = getInternalSlots(loc);
|
|
@@ -4416,13 +4435,25 @@ function translateCharacterOrder(order) {
|
|
|
4416
4435
|
return "ltr";
|
|
4417
4436
|
}
|
|
4418
4437
|
function characterDirectionOfLocale(loc) {
|
|
4419
|
-
|
|
4438
|
+
const locale = loc.minimize().toString();
|
|
4439
|
+
return translateCharacterOrder(characterOrders[locale]);
|
|
4420
4440
|
}
|
|
4421
|
-
function
|
|
4441
|
+
function regionPreference(loc) {
|
|
4422
4442
|
const locale = getInternalSlots(loc).locale;
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4443
|
+
const ast = parseUnicodeLocaleId(locale);
|
|
4444
|
+
const extension = ast.extensions.find((ext) => ext.type === "u");
|
|
4445
|
+
const subdivisionRegion = (key) => {
|
|
4446
|
+
const match = (extension?.keywords.find((entry) => entry[0] === key)?.[1])?.match(/^([a-z]{2}|[0-9]{3})[a-z0-9]{1,4}$/i);
|
|
4447
|
+
return match ? new Locale(`und-${match[1]}`).region : void 0;
|
|
4448
|
+
};
|
|
4449
|
+
return {
|
|
4450
|
+
region: ast.lang.region || subdivisionRegion("sd") || parseUnicodeLanguageId(addLikelySubtags(locale)).region || "001",
|
|
4451
|
+
regionOverride: subdivisionRegion("rg")
|
|
4452
|
+
};
|
|
4453
|
+
}
|
|
4454
|
+
function weekInfoOfLocale(loc) {
|
|
4455
|
+
const { region, regionOverride } = regionPreference(loc);
|
|
4456
|
+
return getWeekDataForRegion(region, regionOverride);
|
|
4426
4457
|
}
|
|
4427
4458
|
const TABLE_1 = [
|
|
4428
4459
|
"sun",
|
|
@@ -4434,7 +4465,7 @@ const TABLE_1 = [
|
|
|
4434
4465
|
"sat"
|
|
4435
4466
|
];
|
|
4436
4467
|
function weekdayToString(fw) {
|
|
4437
|
-
return TABLE_1[
|
|
4468
|
+
return /^[0-7]$/.test(fw) ? TABLE_1[Number(fw) % 7] : fw;
|
|
4438
4469
|
}
|
|
4439
4470
|
var Locale = class Locale {
|
|
4440
4471
|
constructor(tag, opts) {
|
|
@@ -4451,30 +4482,30 @@ var Locale = class Locale {
|
|
|
4451
4482
|
if (relevantExtensionKeys.indexOf("kf") > -1) internalSlotsList.push("caseFirst");
|
|
4452
4483
|
if (relevantExtensionKeys.indexOf("kn") > -1) internalSlotsList.push("numeric");
|
|
4453
4484
|
if (tag === void 0) throw new TypeError("First argument to Intl.Locale constructor can't be empty or missing");
|
|
4454
|
-
if (typeof tag !== "string" && typeof tag !== "object") throw new TypeError("tag must be a string or object");
|
|
4485
|
+
if (tag === null || typeof tag !== "string" && typeof tag !== "object" && typeof tag !== "function") throw new TypeError("tag must be a string or object");
|
|
4455
4486
|
let tagInternalSlots;
|
|
4456
|
-
if (typeof tag === "object" && (tagInternalSlots =
|
|
4457
|
-
else tag = tag
|
|
4487
|
+
if (typeof tag === "object" && (tagInternalSlots = getInternalSlotsIfPresent(tag)) && HasOwnProperty(tagInternalSlots, "initializedLocale")) tag = tagInternalSlots.locale;
|
|
4488
|
+
else tag = ToString(tag);
|
|
4458
4489
|
let internalSlots = getInternalSlots(this, internalSlotsList);
|
|
4459
4490
|
let options = CoerceOptionsToObject(opts);
|
|
4460
4491
|
tag = applyOptionsToTag(tag, options);
|
|
4461
4492
|
const opt = Object.create(null);
|
|
4462
4493
|
const calendar = GetOption(options, "calendar", "string", void 0, void 0);
|
|
4463
4494
|
if (calendar !== void 0) {
|
|
4464
|
-
if (!
|
|
4495
|
+
if (!IsUnicodeLocaleIdentifierType(calendar)) throw new RangeError("invalid calendar");
|
|
4465
4496
|
}
|
|
4466
4497
|
opt.ca = calendar;
|
|
4467
4498
|
const collation = GetOption(options, "collation", "string", void 0, void 0);
|
|
4468
4499
|
if (collation !== void 0) {
|
|
4469
|
-
if (!
|
|
4500
|
+
if (!IsUnicodeLocaleIdentifierType(collation)) throw new RangeError("invalid collation");
|
|
4470
4501
|
}
|
|
4471
4502
|
opt.co = collation;
|
|
4472
4503
|
let fw = GetOption(options, "firstDayOfWeek", "string", void 0, void 0);
|
|
4473
4504
|
if (fw !== void 0) {
|
|
4474
4505
|
fw = weekdayToString(fw);
|
|
4475
|
-
if (!
|
|
4506
|
+
if (!IsUnicodeLocaleIdentifierType(fw)) throw new RangeError("Invalid firstDayOfWeek");
|
|
4476
4507
|
}
|
|
4477
|
-
opt.fw = fw;
|
|
4508
|
+
opt.fw = fw?.toLowerCase();
|
|
4478
4509
|
opt.hc = GetOption(options, "hourCycle", "string", [
|
|
4479
4510
|
"h11",
|
|
4480
4511
|
"h12",
|
|
@@ -4492,7 +4523,7 @@ var Locale = class Locale {
|
|
|
4492
4523
|
opt.kn = kn;
|
|
4493
4524
|
const numberingSystem = GetOption(options, "numberingSystem", "string", void 0, void 0);
|
|
4494
4525
|
if (numberingSystem !== void 0) {
|
|
4495
|
-
if (!
|
|
4526
|
+
if (!IsUnicodeLocaleIdentifierType(numberingSystem)) throw new RangeError("Invalid numberingSystem");
|
|
4496
4527
|
}
|
|
4497
4528
|
opt.nu = numberingSystem;
|
|
4498
4529
|
const r = applyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys);
|
|
@@ -4502,7 +4533,7 @@ var Locale = class Locale {
|
|
|
4502
4533
|
internalSlots.firstDayOfWeek = r.fw;
|
|
4503
4534
|
internalSlots.hourCycle = r.hc;
|
|
4504
4535
|
if (relevantExtensionKeys.indexOf("kf") > -1) internalSlots.caseFirst = r.kf;
|
|
4505
|
-
if (relevantExtensionKeys.indexOf("kn") > -1) internalSlots.numeric = SameValue(r.kn, "true");
|
|
4536
|
+
if (relevantExtensionKeys.indexOf("kn") > -1) internalSlots.numeric = r.kn === "" || SameValue(r.kn, "true");
|
|
4506
4537
|
internalSlots.numberingSystem = r.nu;
|
|
4507
4538
|
}
|
|
4508
4539
|
/**
|
|
@@ -4511,7 +4542,8 @@ var Locale = class Locale {
|
|
|
4511
4542
|
maximize() {
|
|
4512
4543
|
const locale = getInternalSlots(this).locale;
|
|
4513
4544
|
try {
|
|
4514
|
-
|
|
4545
|
+
const maximizedLocale = addLikelySubtags(locale);
|
|
4546
|
+
return new Locale(maximizedLocale);
|
|
4515
4547
|
} catch {
|
|
4516
4548
|
return new Locale(locale);
|
|
4517
4549
|
}
|
|
@@ -4522,13 +4554,16 @@ var Locale = class Locale {
|
|
|
4522
4554
|
minimize() {
|
|
4523
4555
|
const locale = getInternalSlots(this).locale;
|
|
4524
4556
|
try {
|
|
4525
|
-
|
|
4557
|
+
const minimizedLocale = removeLikelySubtags(locale);
|
|
4558
|
+
return new Locale(minimizedLocale);
|
|
4526
4559
|
} catch {
|
|
4527
4560
|
return new Locale(locale);
|
|
4528
4561
|
}
|
|
4529
4562
|
}
|
|
4530
4563
|
toString() {
|
|
4531
|
-
|
|
4564
|
+
const slots = getInternalSlots(this);
|
|
4565
|
+
if (!HasOwnProperty(slots, "initializedLocale")) throw new TypeError("Error uninitialized locale");
|
|
4566
|
+
return slots.locale;
|
|
4532
4567
|
}
|
|
4533
4568
|
get baseName() {
|
|
4534
4569
|
const locale = getInternalSlots(this).locale;
|
|
@@ -4642,7 +4677,9 @@ var Locale = class Locale {
|
|
|
4642
4677
|
}
|
|
4643
4678
|
/**
|
|
4644
4679
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
|
|
4645
|
-
*
|
|
4680
|
+
* ECMA-402 §15.3.22 Intl.Locale.prototype.getWeekInfo, steps 3–7.
|
|
4681
|
+
* https://tc39.es/ecma402/#sec-Intl.Locale.prototype.getWeekInfo
|
|
4682
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/locale.html#L420-L424
|
|
4646
4683
|
*/
|
|
4647
4684
|
getWeekInfo() {
|
|
4648
4685
|
const info = Object.create(Object.prototype);
|
|
@@ -4651,10 +4688,10 @@ var Locale = class Locale {
|
|
|
4651
4688
|
const wi = weekInfoOfLocale(this);
|
|
4652
4689
|
const we = wi.weekend;
|
|
4653
4690
|
createDataProperty(info, "firstDay", wi.firstDay);
|
|
4654
|
-
createDataProperty(info, "weekend", we);
|
|
4655
|
-
createDataProperty(info, "minimalDays", wi.minimalDays);
|
|
4691
|
+
createDataProperty(info, "weekend", [...we]);
|
|
4656
4692
|
const fw = internalSlots.firstDayOfWeek;
|
|
4657
|
-
|
|
4693
|
+
const day = TABLE_1.indexOf(fw);
|
|
4694
|
+
if (day !== -1) info.firstDay = day || 7;
|
|
4658
4695
|
return info;
|
|
4659
4696
|
}
|
|
4660
4697
|
static {
|