@formatjs/intl-locale 3.4.1 → 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/package.json +4 -4
- package/polyfill.iife.js +31 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-locale",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Intl.Locale polyfill",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"tslib": "^2.4.0",
|
|
28
|
-
"@formatjs/ecma402-abstract": "1.17.
|
|
29
|
-
"@formatjs/intl-
|
|
30
|
-
"@formatjs/intl-
|
|
28
|
+
"@formatjs/ecma402-abstract": "1.17.4",
|
|
29
|
+
"@formatjs/intl-enumerator": "1.4.2",
|
|
30
|
+
"@formatjs/intl-getcanonicallocales": "2.3.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/polyfill.iife.js
CHANGED
|
@@ -7233,23 +7233,34 @@
|
|
|
7233
7233
|
return matchingDistance;
|
|
7234
7234
|
}
|
|
7235
7235
|
exports.findMatchingDistance = findMatchingDistance;
|
|
7236
|
-
function findBestMatch(
|
|
7236
|
+
function findBestMatch(requestedLocales, supportedLocales, threshold) {
|
|
7237
7237
|
if (threshold === void 0) {
|
|
7238
7238
|
threshold = DEFAULT_MATCHING_THRESHOLD;
|
|
7239
7239
|
}
|
|
7240
|
-
var bestMatch = void 0;
|
|
7241
7240
|
var lowestDistance = Infinity;
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7241
|
+
var result = {
|
|
7242
|
+
matchedDesiredLocale: "",
|
|
7243
|
+
distances: {}
|
|
7244
|
+
};
|
|
7245
|
+
requestedLocales.forEach(function(desired, i) {
|
|
7246
|
+
if (!result.distances[desired]) {
|
|
7247
|
+
result.distances[desired] = {};
|
|
7247
7248
|
}
|
|
7249
|
+
supportedLocales.forEach(function(supported, j) {
|
|
7250
|
+
var distance = findMatchingDistance(desired, supported) + j + i * 40;
|
|
7251
|
+
result.distances[desired][supported] = distance;
|
|
7252
|
+
if (distance < lowestDistance) {
|
|
7253
|
+
lowestDistance = distance;
|
|
7254
|
+
result.matchedDesiredLocale = desired;
|
|
7255
|
+
result.matchedSupportedLocale = supported;
|
|
7256
|
+
}
|
|
7257
|
+
});
|
|
7248
7258
|
});
|
|
7249
7259
|
if (lowestDistance >= threshold) {
|
|
7250
|
-
|
|
7260
|
+
result.matchedDesiredLocale = void 0;
|
|
7261
|
+
result.matchedSupportedLocale = void 0;
|
|
7251
7262
|
}
|
|
7252
|
-
return
|
|
7263
|
+
return result;
|
|
7253
7264
|
}
|
|
7254
7265
|
exports.findBestMatch = findBestMatch;
|
|
7255
7266
|
}
|
|
@@ -7265,15 +7276,17 @@
|
|
|
7265
7276
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
7266
7277
|
var foundLocale;
|
|
7267
7278
|
var extension;
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
var
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7279
|
+
var noExtensionLocales = [];
|
|
7280
|
+
var noExtensionLocaleMap = requestedLocales.reduce(function(all, l) {
|
|
7281
|
+
var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
7282
|
+
noExtensionLocales.push(noExtensionLocale);
|
|
7283
|
+
all[noExtensionLocale] = l;
|
|
7284
|
+
return all;
|
|
7285
|
+
}, {});
|
|
7286
|
+
var result = (0, utils_1.findBestMatch)(noExtensionLocales, availableLocales);
|
|
7287
|
+
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
|
|
7288
|
+
foundLocale = result.matchedSupportedLocale;
|
|
7289
|
+
extension = noExtensionLocaleMap[result.matchedDesiredLocale].slice(result.matchedDesiredLocale.length) || void 0;
|
|
7277
7290
|
}
|
|
7278
7291
|
if (!foundLocale) {
|
|
7279
7292
|
return { locale: getDefaultLocale() };
|