@formatjs/intl-relativetimeformat 11.2.8 → 11.2.9
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 +6 -6
- package/polyfill.iife.js +31 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-relativetimeformat",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.9",
|
|
4
4
|
"description": "Formats JavaScript dates to relative time strings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"tslib": "^2.4.0",
|
|
24
|
-
"@formatjs/
|
|
25
|
-
"@formatjs/
|
|
24
|
+
"@formatjs/intl-localematcher": "0.5.1",
|
|
25
|
+
"@formatjs/ecma402-abstract": "1.17.4"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@formatjs/intl-
|
|
29
|
-
"@formatjs/intl-
|
|
30
|
-
"@formatjs/intl-
|
|
28
|
+
"@formatjs/intl-pluralrules": "5.2.9",
|
|
29
|
+
"@formatjs/intl-locale": "3.4.2",
|
|
30
|
+
"@formatjs/intl-getcanonicallocales": "2.3.0"
|
|
31
31
|
},
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"types": "index.d.ts",
|
package/polyfill.iife.js
CHANGED
|
@@ -6919,23 +6919,34 @@
|
|
|
6919
6919
|
return matchingDistance;
|
|
6920
6920
|
}
|
|
6921
6921
|
exports.findMatchingDistance = findMatchingDistance;
|
|
6922
|
-
function findBestMatch(
|
|
6922
|
+
function findBestMatch(requestedLocales, supportedLocales, threshold) {
|
|
6923
6923
|
if (threshold === void 0) {
|
|
6924
6924
|
threshold = DEFAULT_MATCHING_THRESHOLD;
|
|
6925
6925
|
}
|
|
6926
|
-
var bestMatch = void 0;
|
|
6927
6926
|
var lowestDistance = Infinity;
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6927
|
+
var result = {
|
|
6928
|
+
matchedDesiredLocale: "",
|
|
6929
|
+
distances: {}
|
|
6930
|
+
};
|
|
6931
|
+
requestedLocales.forEach(function(desired, i) {
|
|
6932
|
+
if (!result.distances[desired]) {
|
|
6933
|
+
result.distances[desired] = {};
|
|
6933
6934
|
}
|
|
6935
|
+
supportedLocales.forEach(function(supported, j) {
|
|
6936
|
+
var distance = findMatchingDistance(desired, supported) + j + i * 40;
|
|
6937
|
+
result.distances[desired][supported] = distance;
|
|
6938
|
+
if (distance < lowestDistance) {
|
|
6939
|
+
lowestDistance = distance;
|
|
6940
|
+
result.matchedDesiredLocale = desired;
|
|
6941
|
+
result.matchedSupportedLocale = supported;
|
|
6942
|
+
}
|
|
6943
|
+
});
|
|
6934
6944
|
});
|
|
6935
6945
|
if (lowestDistance >= threshold) {
|
|
6936
|
-
|
|
6946
|
+
result.matchedDesiredLocale = void 0;
|
|
6947
|
+
result.matchedSupportedLocale = void 0;
|
|
6937
6948
|
}
|
|
6938
|
-
return
|
|
6949
|
+
return result;
|
|
6939
6950
|
}
|
|
6940
6951
|
exports.findBestMatch = findBestMatch;
|
|
6941
6952
|
}
|
|
@@ -6951,15 +6962,17 @@
|
|
|
6951
6962
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
6952
6963
|
var foundLocale;
|
|
6953
6964
|
var extension;
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
var
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6965
|
+
var noExtensionLocales = [];
|
|
6966
|
+
var noExtensionLocaleMap = requestedLocales.reduce(function(all, l) {
|
|
6967
|
+
var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
6968
|
+
noExtensionLocales.push(noExtensionLocale);
|
|
6969
|
+
all[noExtensionLocale] = l;
|
|
6970
|
+
return all;
|
|
6971
|
+
}, {});
|
|
6972
|
+
var result = (0, utils_1.findBestMatch)(noExtensionLocales, availableLocales);
|
|
6973
|
+
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
|
|
6974
|
+
foundLocale = result.matchedSupportedLocale;
|
|
6975
|
+
extension = noExtensionLocaleMap[result.matchedDesiredLocale].slice(result.matchedDesiredLocale.length) || void 0;
|
|
6963
6976
|
}
|
|
6964
6977
|
if (!foundLocale) {
|
|
6965
6978
|
return { locale: getDefaultLocale() };
|