@formatjs/intl-pluralrules 4.0.28 → 4.1.3
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/abstract/InitializePluralRules.d.ts.map +1 -1
- package/abstract/InitializePluralRules.js +2 -1
- package/lib/abstract/InitializePluralRules.d.ts.map +1 -1
- package/lib/abstract/InitializePluralRules.js +2 -1
- package/lib/should-polyfill.d.ts +1 -1
- package/lib/should-polyfill.d.ts.map +1 -1
- package/lib/should-polyfill.js +10 -2
- package/package.json +3 -2
- package/polyfill.iife.js +350 -197
- package/should-polyfill.d.ts +1 -1
- package/should-polyfill.d.ts.map +1 -1
- package/should-polyfill.js +10 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAKhB,MAAM,4BAA4B,CAAA;AAGnC,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,kBAAkB,GAAG,SAAS,EAC5C,EACE,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC,CAAA;IACvD,gBAAgB,IAAI,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;CAC5D,oBAkCF"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InitializePluralRules = void 0;
|
|
4
4
|
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
+
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
5
6
|
function InitializePluralRules(pl, locales, options, _a) {
|
|
6
7
|
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
7
8
|
var requestedLocales = ecma402_abstract_1.CanonicalizeLocaleList(locales);
|
|
@@ -13,7 +14,7 @@ function InitializePluralRules(pl, locales, options, _a) {
|
|
|
13
14
|
opt.localeMatcher = matcher;
|
|
14
15
|
internalSlots.type = ecma402_abstract_1.GetOption(opts, 'type', 'string', ['cardinal', 'ordinal'], 'cardinal');
|
|
15
16
|
ecma402_abstract_1.SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, 'standard');
|
|
16
|
-
var r =
|
|
17
|
+
var r = intl_localematcher_1.ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
17
18
|
internalSlots.locale = r.locale;
|
|
18
19
|
return pl;
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAKhB,MAAM,4BAA4B,CAAA;AAGnC,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,kBAAkB,GAAG,SAAS,EAC5C,EACE,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC,CAAA;IACvD,gBAAgB,IAAI,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;CAC5D,oBAkCF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, SetNumberFormatDigitOptions,
|
|
1
|
+
import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, SetNumberFormatDigitOptions, } from '@formatjs/ecma402-abstract';
|
|
2
|
+
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
2
3
|
export function InitializePluralRules(pl, locales, options, _a) {
|
|
3
4
|
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
4
5
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
package/lib/should-polyfill.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function shouldPolyfill(): boolean;
|
|
1
|
+
export declare function shouldPolyfill(locale?: string | string[]): boolean;
|
|
2
2
|
//# sourceMappingURL=should-polyfill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/should-polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/should-polyfill.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAOxD"}
|
package/lib/should-polyfill.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
function supportedLocalesOf(locale) {
|
|
2
|
+
if (!locale) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
var locales = Array.isArray(locale) ? locale : [locale];
|
|
6
|
+
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
|
|
7
|
+
}
|
|
8
|
+
export function shouldPolyfill(locale) {
|
|
2
9
|
return (!('PluralRules' in Intl) ||
|
|
3
10
|
new Intl.PluralRules('en', { minimumFractionDigits: 2 }).select(1) ===
|
|
4
|
-
'one'
|
|
11
|
+
'one' ||
|
|
12
|
+
!supportedLocalesOf(locale));
|
|
5
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/intl-pluralrules",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Polyfill for Intl.PluralRules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyfill",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"url": "git+https://github.com/formatjs/formatjs.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@formatjs/ecma402-abstract": "1.9.
|
|
23
|
+
"@formatjs/ecma402-abstract": "1.9.8",
|
|
24
|
+
"@formatjs/intl-localematcher": "0.2.20",
|
|
24
25
|
"tslib": "^2.1.0"
|
|
25
26
|
},
|
|
26
27
|
"bugs": {
|
package/polyfill.iife.js
CHANGED
|
@@ -1,4 +1,338 @@
|
|
|
1
1
|
(function() {
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __markAsModule = function(target) {
|
|
9
|
+
return __defProp(target, "__esModule", {value: true});
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = function(cb, mod) {
|
|
12
|
+
return function __require() {
|
|
13
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = {exports: {}}).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var __reExport = function(target, module, desc) {
|
|
17
|
+
if (module && typeof module === "object" || typeof module === "function")
|
|
18
|
+
for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
21
|
+
__defProp(target, key, {get: function(k) {
|
|
22
|
+
return module[k];
|
|
23
|
+
}.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
var __toModule = function(module) {
|
|
28
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: function() {
|
|
29
|
+
return module.default;
|
|
30
|
+
}, enumerable: true} : {value: module, enumerable: true})), module);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js
|
|
34
|
+
var require_utils = __commonJS({
|
|
35
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
38
|
+
exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
|
|
39
|
+
exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
40
|
+
function invariant2(condition, message, Err) {
|
|
41
|
+
if (Err === void 0) {
|
|
42
|
+
Err = Error;
|
|
43
|
+
}
|
|
44
|
+
if (!condition) {
|
|
45
|
+
throw new Err(message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.invariant = invariant2;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js
|
|
53
|
+
var require_BestAvailableLocale = __commonJS({
|
|
54
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js": function(exports) {
|
|
55
|
+
"use strict";
|
|
56
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
57
|
+
exports.BestAvailableLocale = void 0;
|
|
58
|
+
function BestAvailableLocale(availableLocales, locale) {
|
|
59
|
+
var candidate = locale;
|
|
60
|
+
while (true) {
|
|
61
|
+
if (availableLocales.has(candidate)) {
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
var pos = candidate.lastIndexOf("-");
|
|
65
|
+
if (!~pos) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
if (pos >= 2 && candidate[pos - 2] === "-") {
|
|
69
|
+
pos -= 2;
|
|
70
|
+
}
|
|
71
|
+
candidate = candidate.slice(0, pos);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.BestAvailableLocale = BestAvailableLocale;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js
|
|
79
|
+
var require_LookupMatcher = __commonJS({
|
|
80
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js": function(exports) {
|
|
81
|
+
"use strict";
|
|
82
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
83
|
+
exports.LookupMatcher = void 0;
|
|
84
|
+
var utils_1 = require_utils();
|
|
85
|
+
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
86
|
+
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
87
|
+
var result = {locale: ""};
|
|
88
|
+
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
89
|
+
var locale = requestedLocales_1[_i];
|
|
90
|
+
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
91
|
+
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
92
|
+
if (availableLocale) {
|
|
93
|
+
result.locale = availableLocale;
|
|
94
|
+
if (locale !== noExtensionLocale) {
|
|
95
|
+
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
result.locale = getDefaultLocale();
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
exports.LookupMatcher = LookupMatcher;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js
|
|
108
|
+
var require_BestFitMatcher = __commonJS({
|
|
109
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js": function(exports) {
|
|
110
|
+
"use strict";
|
|
111
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
112
|
+
exports.BestFitMatcher = void 0;
|
|
113
|
+
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
114
|
+
var utils_1 = require_utils();
|
|
115
|
+
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
116
|
+
var minimizedAvailableLocaleMap = Array.from(availableLocales).reduce(function(all, l2) {
|
|
117
|
+
all[l2] = l2;
|
|
118
|
+
return all;
|
|
119
|
+
}, {});
|
|
120
|
+
var minimizedAvailableLocales = new Set();
|
|
121
|
+
availableLocales.forEach(function(locale2) {
|
|
122
|
+
var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
|
123
|
+
minimizedAvailableLocaleMap[minimizedLocale] = locale2;
|
|
124
|
+
minimizedAvailableLocales.add(minimizedLocale);
|
|
125
|
+
});
|
|
126
|
+
var foundLocale;
|
|
127
|
+
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
128
|
+
var l = requestedLocales_1[_i];
|
|
129
|
+
if (foundLocale) {
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
133
|
+
if (availableLocales.has(noExtensionLocale)) {
|
|
134
|
+
foundLocale = noExtensionLocale;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (minimizedAvailableLocales.has(noExtensionLocale)) {
|
|
138
|
+
foundLocale = noExtensionLocale;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
var locale = new Intl.Locale(noExtensionLocale);
|
|
142
|
+
var maximizedRequestedLocale = locale.maximize().toString();
|
|
143
|
+
var minimizedRequestedLocale = locale.minimize().toString();
|
|
144
|
+
if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
|
|
145
|
+
foundLocale = minimizedRequestedLocale;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
exports.BestFitMatcher = BestFitMatcher;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js
|
|
159
|
+
var require_UnicodeExtensionValue = __commonJS({
|
|
160
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js": function(exports) {
|
|
161
|
+
"use strict";
|
|
162
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
163
|
+
exports.UnicodeExtensionValue = void 0;
|
|
164
|
+
var utils_1 = require_utils();
|
|
165
|
+
function UnicodeExtensionValue(extension, key) {
|
|
166
|
+
utils_1.invariant(key.length === 2, "key must have 2 elements");
|
|
167
|
+
var size = extension.length;
|
|
168
|
+
var searchValue = "-" + key + "-";
|
|
169
|
+
var pos = extension.indexOf(searchValue);
|
|
170
|
+
if (pos !== -1) {
|
|
171
|
+
var start = pos + 4;
|
|
172
|
+
var end = start;
|
|
173
|
+
var k = start;
|
|
174
|
+
var done = false;
|
|
175
|
+
while (!done) {
|
|
176
|
+
var e = extension.indexOf("-", k);
|
|
177
|
+
var len = void 0;
|
|
178
|
+
if (e === -1) {
|
|
179
|
+
len = size - k;
|
|
180
|
+
} else {
|
|
181
|
+
len = e - k;
|
|
182
|
+
}
|
|
183
|
+
if (len === 2) {
|
|
184
|
+
done = true;
|
|
185
|
+
} else if (e === -1) {
|
|
186
|
+
end = size;
|
|
187
|
+
done = true;
|
|
188
|
+
} else {
|
|
189
|
+
end = e;
|
|
190
|
+
k = e + 1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return extension.slice(start, end);
|
|
194
|
+
}
|
|
195
|
+
searchValue = "-" + key;
|
|
196
|
+
pos = extension.indexOf(searchValue);
|
|
197
|
+
if (pos !== -1 && pos + 3 === size) {
|
|
198
|
+
return "";
|
|
199
|
+
}
|
|
200
|
+
return void 0;
|
|
201
|
+
}
|
|
202
|
+
exports.UnicodeExtensionValue = UnicodeExtensionValue;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js
|
|
207
|
+
var require_ResolveLocale = __commonJS({
|
|
208
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js": function(exports) {
|
|
209
|
+
"use strict";
|
|
210
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
211
|
+
exports.ResolveLocale = void 0;
|
|
212
|
+
var LookupMatcher_1 = require_LookupMatcher();
|
|
213
|
+
var BestFitMatcher_1 = require_BestFitMatcher();
|
|
214
|
+
var utils_1 = require_utils();
|
|
215
|
+
var UnicodeExtensionValue_1 = require_UnicodeExtensionValue();
|
|
216
|
+
function ResolveLocale3(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
217
|
+
var matcher = options.localeMatcher;
|
|
218
|
+
var r;
|
|
219
|
+
if (matcher === "lookup") {
|
|
220
|
+
r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
221
|
+
} else {
|
|
222
|
+
r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
223
|
+
}
|
|
224
|
+
var foundLocale = r.locale;
|
|
225
|
+
var result = {locale: "", dataLocale: foundLocale};
|
|
226
|
+
var supportedExtension = "-u";
|
|
227
|
+
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
228
|
+
var key = relevantExtensionKeys_1[_i];
|
|
229
|
+
utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
230
|
+
var foundLocaleData = localeData[foundLocale];
|
|
231
|
+
utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
232
|
+
var keyLocaleData = foundLocaleData[key];
|
|
233
|
+
utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
234
|
+
var value = keyLocaleData[0];
|
|
235
|
+
utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
236
|
+
var supportedExtensionAddition = "";
|
|
237
|
+
if (r.extension) {
|
|
238
|
+
var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
|
|
239
|
+
if (requestedValue !== void 0) {
|
|
240
|
+
if (requestedValue !== "") {
|
|
241
|
+
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
242
|
+
value = requestedValue;
|
|
243
|
+
supportedExtensionAddition = "-" + key + "-" + value;
|
|
244
|
+
}
|
|
245
|
+
} else if (~requestedValue.indexOf("true")) {
|
|
246
|
+
value = "true";
|
|
247
|
+
supportedExtensionAddition = "-" + key;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (key in options) {
|
|
252
|
+
var optionsValue = options[key];
|
|
253
|
+
utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
254
|
+
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
255
|
+
if (optionsValue !== value) {
|
|
256
|
+
value = optionsValue;
|
|
257
|
+
supportedExtensionAddition = "";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
result[key] = value;
|
|
262
|
+
supportedExtension += supportedExtensionAddition;
|
|
263
|
+
}
|
|
264
|
+
if (supportedExtension.length > 2) {
|
|
265
|
+
var privateIndex = foundLocale.indexOf("-x-");
|
|
266
|
+
if (privateIndex === -1) {
|
|
267
|
+
foundLocale = foundLocale + supportedExtension;
|
|
268
|
+
} else {
|
|
269
|
+
var preExtension = foundLocale.slice(0, privateIndex);
|
|
270
|
+
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
271
|
+
foundLocale = preExtension + supportedExtension + postExtension;
|
|
272
|
+
}
|
|
273
|
+
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
|
274
|
+
}
|
|
275
|
+
result.locale = foundLocale;
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
exports.ResolveLocale = ResolveLocale3;
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js
|
|
283
|
+
var require_LookupSupportedLocales = __commonJS({
|
|
284
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js": function(exports) {
|
|
285
|
+
"use strict";
|
|
286
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
287
|
+
exports.LookupSupportedLocales = void 0;
|
|
288
|
+
var utils_1 = require_utils();
|
|
289
|
+
var BestAvailableLocale_1 = require_BestAvailableLocale();
|
|
290
|
+
function LookupSupportedLocales2(availableLocales, requestedLocales) {
|
|
291
|
+
var subset = [];
|
|
292
|
+
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
293
|
+
var locale = requestedLocales_1[_i];
|
|
294
|
+
var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
295
|
+
var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
296
|
+
if (availableLocale) {
|
|
297
|
+
subset.push(availableLocale);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return subset;
|
|
301
|
+
}
|
|
302
|
+
exports.LookupSupportedLocales = LookupSupportedLocales2;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js
|
|
307
|
+
var require_intl_localematcher = __commonJS({
|
|
308
|
+
"bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js": function(exports) {
|
|
309
|
+
"use strict";
|
|
310
|
+
Object.defineProperty(exports, "__esModule", {value: true});
|
|
311
|
+
exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
|
|
312
|
+
var ResolveLocale_1 = require_ResolveLocale();
|
|
313
|
+
function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
|
314
|
+
var locales = availableLocales.reduce(function(all, l) {
|
|
315
|
+
all.add(l);
|
|
316
|
+
return all;
|
|
317
|
+
}, new Set());
|
|
318
|
+
return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
|
|
319
|
+
localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
|
320
|
+
}, [], {}, function() {
|
|
321
|
+
return defaultLocale;
|
|
322
|
+
}).locale;
|
|
323
|
+
}
|
|
324
|
+
exports.match = match;
|
|
325
|
+
var LookupSupportedLocales_1 = require_LookupSupportedLocales();
|
|
326
|
+
Object.defineProperty(exports, "LookupSupportedLocales", {enumerable: true, get: function() {
|
|
327
|
+
return LookupSupportedLocales_1.LookupSupportedLocales;
|
|
328
|
+
}});
|
|
329
|
+
var ResolveLocale_2 = require_ResolveLocale();
|
|
330
|
+
Object.defineProperty(exports, "ResolveLocale", {enumerable: true, get: function() {
|
|
331
|
+
return ResolveLocale_2.ResolveLocale;
|
|
332
|
+
}});
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
2
336
|
// node_modules/tslib/tslib.es6.js
|
|
3
337
|
var extendStatics = function(d, b) {
|
|
4
338
|
extendStatics = Object.setPrototypeOf || {__proto__: []} instanceof Array && function(d2, b2) {
|
|
@@ -225,7 +559,6 @@
|
|
|
225
559
|
}
|
|
226
560
|
return arr.join("");
|
|
227
561
|
}
|
|
228
|
-
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
229
562
|
function invariant(condition, message, Err) {
|
|
230
563
|
if (Err === void 0) {
|
|
231
564
|
Err = Error;
|
|
@@ -376,183 +709,8 @@
|
|
|
376
709
|
var CARET_S_UNICODE_REGEX = new RegExp("^" + S_UNICODE_REGEX.source);
|
|
377
710
|
var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source + "$");
|
|
378
711
|
|
|
379
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/
|
|
380
|
-
|
|
381
|
-
var candidate = locale;
|
|
382
|
-
while (true) {
|
|
383
|
-
if (availableLocales.has(candidate)) {
|
|
384
|
-
return candidate;
|
|
385
|
-
}
|
|
386
|
-
var pos = candidate.lastIndexOf("-");
|
|
387
|
-
if (!~pos) {
|
|
388
|
-
return void 0;
|
|
389
|
-
}
|
|
390
|
-
if (pos >= 2 && candidate[pos - 2] === "-") {
|
|
391
|
-
pos -= 2;
|
|
392
|
-
}
|
|
393
|
-
candidate = candidate.slice(0, pos);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/LookupMatcher.js
|
|
398
|
-
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
399
|
-
var result = {locale: ""};
|
|
400
|
-
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
401
|
-
var locale = requestedLocales_1[_i];
|
|
402
|
-
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
403
|
-
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
404
|
-
if (availableLocale) {
|
|
405
|
-
result.locale = availableLocale;
|
|
406
|
-
if (locale !== noExtensionLocale) {
|
|
407
|
-
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
|
|
408
|
-
}
|
|
409
|
-
return result;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
result.locale = getDefaultLocale();
|
|
413
|
-
return result;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/BestFitMatcher.js
|
|
417
|
-
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
418
|
-
var minimizedAvailableLocaleMap = {};
|
|
419
|
-
var minimizedAvailableLocales = new Set();
|
|
420
|
-
availableLocales.forEach(function(locale2) {
|
|
421
|
-
var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
|
422
|
-
minimizedAvailableLocaleMap[minimizedLocale] = locale2;
|
|
423
|
-
minimizedAvailableLocales.add(minimizedLocale);
|
|
424
|
-
});
|
|
425
|
-
var foundLocale;
|
|
426
|
-
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
427
|
-
var l = requestedLocales_1[_i];
|
|
428
|
-
if (foundLocale) {
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
var noExtensionLocale = l.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
432
|
-
if (availableLocales.has(noExtensionLocale)) {
|
|
433
|
-
foundLocale = noExtensionLocale;
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
if (minimizedAvailableLocales.has(noExtensionLocale)) {
|
|
437
|
-
foundLocale = minimizedAvailableLocaleMap[noExtensionLocale];
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
var locale = new Intl.Locale(noExtensionLocale);
|
|
441
|
-
var maximizedRequestedLocale = locale.maximize().toString();
|
|
442
|
-
var minimizedRequestedLocale = locale.minimize().toString();
|
|
443
|
-
if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
|
|
444
|
-
foundLocale = minimizedAvailableLocaleMap[minimizedRequestedLocale];
|
|
445
|
-
break;
|
|
446
|
-
}
|
|
447
|
-
foundLocale = BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
|
448
|
-
}
|
|
449
|
-
return {
|
|
450
|
-
locale: foundLocale || getDefaultLocale()
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/UnicodeExtensionValue.js
|
|
455
|
-
function UnicodeExtensionValue(extension, key) {
|
|
456
|
-
invariant(key.length === 2, "key must have 2 elements");
|
|
457
|
-
var size = extension.length;
|
|
458
|
-
var searchValue = "-" + key + "-";
|
|
459
|
-
var pos = extension.indexOf(searchValue);
|
|
460
|
-
if (pos !== -1) {
|
|
461
|
-
var start = pos + 4;
|
|
462
|
-
var end = start;
|
|
463
|
-
var k = start;
|
|
464
|
-
var done = false;
|
|
465
|
-
while (!done) {
|
|
466
|
-
var e = extension.indexOf("-", k);
|
|
467
|
-
var len = void 0;
|
|
468
|
-
if (e === -1) {
|
|
469
|
-
len = size - k;
|
|
470
|
-
} else {
|
|
471
|
-
len = e - k;
|
|
472
|
-
}
|
|
473
|
-
if (len === 2) {
|
|
474
|
-
done = true;
|
|
475
|
-
} else if (e === -1) {
|
|
476
|
-
end = size;
|
|
477
|
-
done = true;
|
|
478
|
-
} else {
|
|
479
|
-
end = e;
|
|
480
|
-
k = e + 1;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return extension.slice(start, end);
|
|
484
|
-
}
|
|
485
|
-
searchValue = "-" + key;
|
|
486
|
-
pos = extension.indexOf(searchValue);
|
|
487
|
-
if (pos !== -1 && pos + 3 === size) {
|
|
488
|
-
return "";
|
|
489
|
-
}
|
|
490
|
-
return void 0;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/ResolveLocale.js
|
|
494
|
-
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
495
|
-
var matcher = options.localeMatcher;
|
|
496
|
-
var r;
|
|
497
|
-
if (matcher === "lookup") {
|
|
498
|
-
r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
499
|
-
} else {
|
|
500
|
-
r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
|
501
|
-
}
|
|
502
|
-
var foundLocale = r.locale;
|
|
503
|
-
var result = {locale: "", dataLocale: foundLocale};
|
|
504
|
-
var supportedExtension = "-u";
|
|
505
|
-
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
|
506
|
-
var key = relevantExtensionKeys_1[_i];
|
|
507
|
-
invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
|
508
|
-
var foundLocaleData = localeData[foundLocale];
|
|
509
|
-
invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
|
|
510
|
-
var keyLocaleData = foundLocaleData[key];
|
|
511
|
-
invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
|
512
|
-
var value = keyLocaleData[0];
|
|
513
|
-
invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
|
514
|
-
var supportedExtensionAddition = "";
|
|
515
|
-
if (r.extension) {
|
|
516
|
-
var requestedValue = UnicodeExtensionValue(r.extension, key);
|
|
517
|
-
if (requestedValue !== void 0) {
|
|
518
|
-
if (requestedValue !== "") {
|
|
519
|
-
if (~keyLocaleData.indexOf(requestedValue)) {
|
|
520
|
-
value = requestedValue;
|
|
521
|
-
supportedExtensionAddition = "-" + key + "-" + value;
|
|
522
|
-
}
|
|
523
|
-
} else if (~requestedValue.indexOf("true")) {
|
|
524
|
-
value = "true";
|
|
525
|
-
supportedExtensionAddition = "-" + key;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (key in options) {
|
|
530
|
-
var optionsValue = options[key];
|
|
531
|
-
invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
|
532
|
-
if (~keyLocaleData.indexOf(optionsValue)) {
|
|
533
|
-
if (optionsValue !== value) {
|
|
534
|
-
value = optionsValue;
|
|
535
|
-
supportedExtensionAddition = "";
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
result[key] = value;
|
|
540
|
-
supportedExtension += supportedExtensionAddition;
|
|
541
|
-
}
|
|
542
|
-
if (supportedExtension.length > 2) {
|
|
543
|
-
var privateIndex = foundLocale.indexOf("-x-");
|
|
544
|
-
if (privateIndex === -1) {
|
|
545
|
-
foundLocale = foundLocale + supportedExtension;
|
|
546
|
-
} else {
|
|
547
|
-
var preExtension = foundLocale.slice(0, privateIndex);
|
|
548
|
-
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
|
549
|
-
foundLocale = preExtension + supportedExtension + postExtension;
|
|
550
|
-
}
|
|
551
|
-
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
|
552
|
-
}
|
|
553
|
-
result.locale = foundLocale;
|
|
554
|
-
return result;
|
|
555
|
-
}
|
|
712
|
+
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/InitializeNumberFormat.js
|
|
713
|
+
var import_intl_localematcher = __toModule(require_intl_localematcher());
|
|
556
714
|
|
|
557
715
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/NumberFormat/SetNumberFormatDigitOptions.js
|
|
558
716
|
function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefault, notation) {
|
|
@@ -584,21 +742,8 @@
|
|
|
584
742
|
}
|
|
585
743
|
}
|
|
586
744
|
|
|
587
|
-
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/LookupSupportedLocales.js
|
|
588
|
-
function LookupSupportedLocales(availableLocales, requestedLocales) {
|
|
589
|
-
var subset = [];
|
|
590
|
-
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
|
591
|
-
var locale = requestedLocales_1[_i];
|
|
592
|
-
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
|
593
|
-
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
|
|
594
|
-
if (availableLocale) {
|
|
595
|
-
subset.push(availableLocale);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
return subset;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
745
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/SupportedLocales.js
|
|
746
|
+
var import_intl_localematcher2 = __toModule(require_intl_localematcher());
|
|
602
747
|
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
603
748
|
var matcher = "best fit";
|
|
604
749
|
if (options !== void 0) {
|
|
@@ -606,9 +751,9 @@
|
|
|
606
751
|
matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
|
|
607
752
|
}
|
|
608
753
|
if (matcher === "best fit") {
|
|
609
|
-
return LookupSupportedLocales(availableLocales, requestedLocales);
|
|
754
|
+
return (0, import_intl_localematcher2.LookupSupportedLocales)(availableLocales, requestedLocales);
|
|
610
755
|
}
|
|
611
|
-
return LookupSupportedLocales(availableLocales, requestedLocales);
|
|
756
|
+
return (0, import_intl_localematcher2.LookupSupportedLocales)(availableLocales, requestedLocales);
|
|
612
757
|
}
|
|
613
758
|
|
|
614
759
|
// bazel-out/darwin-fastbuild/bin/packages/ecma402-abstract/lib/data.js
|
|
@@ -631,6 +776,7 @@
|
|
|
631
776
|
})(RangePatternType || (RangePatternType = {}));
|
|
632
777
|
|
|
633
778
|
// bazel-out/darwin-fastbuild/bin/packages/intl-pluralrules/lib/abstract/InitializePluralRules.js
|
|
779
|
+
var import_intl_localematcher3 = __toModule(require_intl_localematcher());
|
|
634
780
|
function InitializePluralRules(pl, locales, options, _a) {
|
|
635
781
|
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots2 = _a.getInternalSlots;
|
|
636
782
|
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
@@ -642,7 +788,7 @@
|
|
|
642
788
|
opt.localeMatcher = matcher;
|
|
643
789
|
internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
|
|
644
790
|
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, "standard");
|
|
645
|
-
var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
791
|
+
var r = (0, import_intl_localematcher3.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
646
792
|
internalSlots.locale = r.locale;
|
|
647
793
|
return pl;
|
|
648
794
|
}
|
|
@@ -831,8 +977,15 @@
|
|
|
831
977
|
}
|
|
832
978
|
|
|
833
979
|
// bazel-out/darwin-fastbuild/bin/packages/intl-pluralrules/lib/should-polyfill.js
|
|
834
|
-
function
|
|
835
|
-
|
|
980
|
+
function supportedLocalesOf(locale) {
|
|
981
|
+
if (!locale) {
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
var locales = Array.isArray(locale) ? locale : [locale];
|
|
985
|
+
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
|
|
986
|
+
}
|
|
987
|
+
function shouldPolyfill(locale) {
|
|
988
|
+
return !("PluralRules" in Intl) || new Intl.PluralRules("en", {minimumFractionDigits: 2}).select(1) === "one" || !supportedLocalesOf(locale);
|
|
836
989
|
}
|
|
837
990
|
|
|
838
991
|
// bazel-out/darwin-fastbuild/bin/packages/intl-pluralrules/lib/polyfill.js
|
package/should-polyfill.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function shouldPolyfill(): boolean;
|
|
1
|
+
export declare function shouldPolyfill(locale?: string | string[]): boolean;
|
|
2
2
|
//# sourceMappingURL=should-polyfill.d.ts.map
|
package/should-polyfill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-pluralrules/should-polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should-polyfill.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-pluralrules/should-polyfill.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,WAOxD"}
|
package/should-polyfill.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shouldPolyfill = void 0;
|
|
4
|
-
function
|
|
4
|
+
function supportedLocalesOf(locale) {
|
|
5
|
+
if (!locale) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
var locales = Array.isArray(locale) ? locale : [locale];
|
|
9
|
+
return Intl.PluralRules.supportedLocalesOf(locales).length === locales.length;
|
|
10
|
+
}
|
|
11
|
+
function shouldPolyfill(locale) {
|
|
5
12
|
return (!('PluralRules' in Intl) ||
|
|
6
13
|
new Intl.PluralRules('en', { minimumFractionDigits: 2 }).select(1) ===
|
|
7
|
-
'one'
|
|
14
|
+
'one' ||
|
|
15
|
+
!supportedLocalesOf(locale));
|
|
8
16
|
}
|
|
9
17
|
exports.shouldPolyfill = shouldPolyfill;
|