@formatjs/intl-listformat 6.5.0 → 6.5.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/package.json +3 -3
- package/polyfill.iife.js +28 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-listformat",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.1",
|
|
4
4
|
"description": "Formats JS list in a i18n-safe way",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"url": "git@github.com:formatjs/formatjs.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@formatjs/ecma402-abstract": "1.11.
|
|
23
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
22
|
+
"@formatjs/ecma402-abstract": "1.11.2",
|
|
23
|
+
"@formatjs/intl-localematcher": "0.2.23",
|
|
24
24
|
"tslib": "^2.1.0"
|
|
25
25
|
},
|
|
26
26
|
"main": "index.js",
|
package/polyfill.iife.js
CHANGED
|
@@ -30,6 +30,19 @@
|
|
|
30
30
|
}, enumerable: true } : { value: module, enumerable: true })), module);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js
|
|
34
|
+
var require_CanonicalizeLocaleList = __commonJS({
|
|
35
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/CanonicalizeLocaleList.js": function(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.CanonicalizeLocaleList = void 0;
|
|
39
|
+
function CanonicalizeLocaleList2(locales) {
|
|
40
|
+
return Intl.getCanonicalLocales(locales);
|
|
41
|
+
}
|
|
42
|
+
exports.CanonicalizeLocaleList = CanonicalizeLocaleList2;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
33
46
|
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
|
|
34
47
|
var require_utils = __commonJS({
|
|
35
48
|
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
|
|
@@ -114,14 +127,16 @@
|
|
|
114
127
|
var utils_1 = require_utils();
|
|
115
128
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
116
129
|
var minimizedAvailableLocaleMap = {};
|
|
117
|
-
availableLocales.forEach(function(l2) {
|
|
118
|
-
return minimizedAvailableLocaleMap[l2] = l2;
|
|
119
|
-
});
|
|
120
130
|
var minimizedAvailableLocales = /* @__PURE__ */ new Set();
|
|
121
131
|
availableLocales.forEach(function(locale2) {
|
|
122
132
|
var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
|
133
|
+
var canonicalizedLocale = Intl.getCanonicalLocales(locale2)[0] || locale2;
|
|
123
134
|
minimizedAvailableLocaleMap[minimizedLocale] = locale2;
|
|
135
|
+
minimizedAvailableLocaleMap[locale2] = locale2;
|
|
136
|
+
minimizedAvailableLocaleMap[canonicalizedLocale] = locale2;
|
|
124
137
|
minimizedAvailableLocales.add(minimizedLocale);
|
|
138
|
+
minimizedAvailableLocales.add(locale2);
|
|
139
|
+
minimizedAvailableLocales.add(canonicalizedLocale);
|
|
125
140
|
});
|
|
126
141
|
var foundLocale;
|
|
127
142
|
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
@@ -147,8 +162,11 @@
|
|
|
147
162
|
}
|
|
148
163
|
foundLocale = (0, BestAvailableLocale_1.BestAvailableLocale)(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
149
164
|
}
|
|
165
|
+
if (!foundLocale) {
|
|
166
|
+
return { locale: getDefaultLocale() };
|
|
167
|
+
}
|
|
150
168
|
return {
|
|
151
|
-
locale:
|
|
169
|
+
locale: minimizedAvailableLocaleMap[foundLocale] || foundLocale
|
|
152
170
|
};
|
|
153
171
|
}
|
|
154
172
|
exports.BestFitMatcher = BestFitMatcher;
|
|
@@ -309,13 +327,14 @@
|
|
|
309
327
|
"use strict";
|
|
310
328
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
311
329
|
exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
|
|
330
|
+
var CanonicalizeLocaleList_1 = require_CanonicalizeLocaleList();
|
|
312
331
|
var ResolveLocale_1 = require_ResolveLocale();
|
|
313
332
|
function match2(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
314
333
|
var locales = availableLocales.reduce(function(all, l) {
|
|
315
334
|
all.add(l);
|
|
316
335
|
return all;
|
|
317
336
|
}, /* @__PURE__ */ new Set());
|
|
318
|
-
return (0, ResolveLocale_1.ResolveLocale)(locales, requestedLocales, {
|
|
337
|
+
return (0, ResolveLocale_1.ResolveLocale)(locales, (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(requestedLocales), {
|
|
319
338
|
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
320
339
|
}, [], {}, function() {
|
|
321
340
|
return defaultLocale;
|
|
@@ -400,7 +419,7 @@
|
|
|
400
419
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/GetOptionsObject.js
|
|
401
420
|
function GetOptionsObject(options) {
|
|
402
421
|
if (typeof options === "undefined") {
|
|
403
|
-
return Object.create(null);
|
|
422
|
+
return /* @__PURE__ */ Object.create(null);
|
|
404
423
|
}
|
|
405
424
|
if (typeof options === "object") {
|
|
406
425
|
return options;
|
|
@@ -411,7 +430,7 @@
|
|
|
411
430
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/utils.js
|
|
412
431
|
function setInternalSlot(map, pl, field, value) {
|
|
413
432
|
if (!map.get(pl)) {
|
|
414
|
-
map.set(pl, Object.create(null));
|
|
433
|
+
map.set(pl, /* @__PURE__ */ Object.create(null));
|
|
415
434
|
}
|
|
416
435
|
var slots = map.get(pl);
|
|
417
436
|
slots[field] = value;
|
|
@@ -431,7 +450,7 @@
|
|
|
431
450
|
return fields.reduce(function(all, f) {
|
|
432
451
|
all[f] = slots[f];
|
|
433
452
|
return all;
|
|
434
|
-
}, Object.create(null));
|
|
453
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
435
454
|
}
|
|
436
455
|
function isLiteralPart(patternPart) {
|
|
437
456
|
return patternPart.type === "literal";
|
|
@@ -575,7 +594,7 @@
|
|
|
575
594
|
}
|
|
576
595
|
setInternalSlot(ListFormat2.__INTERNAL_SLOT_MAP__, this, "initializedListFormat", true);
|
|
577
596
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
578
|
-
var opt = Object.create(null);
|
|
597
|
+
var opt = /* @__PURE__ */ Object.create(null);
|
|
579
598
|
var opts = GetOptionsObject(options);
|
|
580
599
|
var matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
581
600
|
opt.localeMatcher = matcher;
|