@formatjs/intl-displaynames 5.4.0 → 5.4.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-displaynames",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"description": "Polyfill for: https://tc39.es/proposal-intl-displaynames",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "git+https://github.com/formatjs/formatjs.git"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@formatjs/ecma402-abstract": "1.11.
|
|
25
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
24
|
+
"@formatjs/ecma402-abstract": "1.11.2",
|
|
25
|
+
"@formatjs/intl-localematcher": "0.2.23",
|
|
26
26
|
"tslib": "^2.1.0"
|
|
27
27
|
},
|
|
28
28
|
"bugs": {
|
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;
|
|
@@ -429,7 +448,7 @@
|
|
|
429
448
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/utils.js
|
|
430
449
|
function setInternalSlot(map, pl, field, value) {
|
|
431
450
|
if (!map.get(pl)) {
|
|
432
|
-
map.set(pl, Object.create(null));
|
|
451
|
+
map.set(pl, /* @__PURE__ */ Object.create(null));
|
|
433
452
|
}
|
|
434
453
|
var slots = map.get(pl);
|
|
435
454
|
slots[field] = value;
|
|
@@ -449,7 +468,7 @@
|
|
|
449
468
|
return fields.reduce(function(all, f) {
|
|
450
469
|
all[f] = slots[f];
|
|
451
470
|
return all;
|
|
452
|
-
}, Object.create(null));
|
|
471
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
453
472
|
}
|
|
454
473
|
function invariant(condition, message, Err) {
|
|
455
474
|
if (Err === void 0) {
|
|
@@ -516,7 +535,7 @@
|
|
|
516
535
|
}
|
|
517
536
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
518
537
|
options = GetOptionsObject(options);
|
|
519
|
-
var opt = Object.create(null);
|
|
538
|
+
var opt = /* @__PURE__ */ Object.create(null);
|
|
520
539
|
var localeData = DisplayNames2.localeData;
|
|
521
540
|
var matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
522
541
|
opt.localeMatcher = matcher;
|