@formatjs/intl-relativetimeformat 9.5.0 → 9.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 +27 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-relativetimeformat",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.1",
|
|
4
4
|
"description": "Formats JavaScript dates to relative time strings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"url": "git@github.com:formatjs/formatjs.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@formatjs/ecma402-abstract": "1.11.
|
|
24
|
-
"@formatjs/intl-localematcher": "0.2.
|
|
23
|
+
"@formatjs/ecma402-abstract": "1.11.2",
|
|
24
|
+
"@formatjs/intl-localematcher": "0.2.23",
|
|
25
25
|
"tslib": "^2.1.0"
|
|
26
26
|
},
|
|
27
27
|
"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;
|
|
@@ -395,7 +414,7 @@
|
|
|
395
414
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/CoerceOptionsToObject.js
|
|
396
415
|
function CoerceOptionsToObject(options) {
|
|
397
416
|
if (typeof options === "undefined") {
|
|
398
|
-
return Object.create(null);
|
|
417
|
+
return /* @__PURE__ */ Object.create(null);
|
|
399
418
|
}
|
|
400
419
|
return ToObject(options);
|
|
401
420
|
}
|
|
@@ -490,7 +509,7 @@
|
|
|
490
509
|
var internalSlots = getInternalSlots2(rtf);
|
|
491
510
|
internalSlots.initializedRelativeTimeFormat = true;
|
|
492
511
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
493
|
-
var opt = Object.create(null);
|
|
512
|
+
var opt = /* @__PURE__ */ Object.create(null);
|
|
494
513
|
var opts = CoerceOptionsToObject(options);
|
|
495
514
|
var matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
|
|
496
515
|
opt.localeMatcher = matcher;
|
|
@@ -618,7 +637,7 @@
|
|
|
618
637
|
function getInternalSlots(x) {
|
|
619
638
|
var internalSlots = internalSlotMap.get(x);
|
|
620
639
|
if (!internalSlots) {
|
|
621
|
-
internalSlots = Object.create(null);
|
|
640
|
+
internalSlots = /* @__PURE__ */ Object.create(null);
|
|
622
641
|
internalSlotMap.set(x, internalSlots);
|
|
623
642
|
}
|
|
624
643
|
return internalSlots;
|