@formatjs/intl-getcanonicallocales 3.1.0 → 3.1.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/index.d.ts +4 -4
- package/index.js +25 -26
- package/package.json +1 -1
- package/polyfill-force.js +13 -19
- package/polyfill.iife.js +335 -335
- package/polyfill.js +15 -21
- package/should-polyfill.js +1 -6
- package/src/aliases.generated.d.ts +2 -0
- package/src/aliases.generated.js +1147 -1149
- package/src/canonicalizer.d.ts +11 -11
- package/src/canonicalizer.js +190 -199
- package/src/emitter.d.ts +2 -2
- package/src/emitter.js +27 -25
- package/src/likelySubtags.generated.d.ts +2 -0
- package/src/likelySubtags.generated.js +7790 -7790
- package/src/parser.d.ts +1 -1
- package/src/parser.js +208 -206
- package/src/types.d.ts +17 -17
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function getCanonicalLocales(locales?: string[] | string): string[];
|
|
2
|
-
export * from
|
|
3
|
-
export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
2
|
+
export * from "./src/emitter.js";
|
|
3
|
+
export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId } from "./src/parser.js";
|
|
4
|
+
export * from "./src/types.js";
|
|
5
|
+
export * from "./src/likelySubtags.generated.js";
|
package/index.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { CanonicalizeUnicodeLocaleId } from
|
|
2
|
-
import { emitUnicodeLocaleId } from
|
|
3
|
-
import { parseUnicodeLocaleId } from
|
|
1
|
+
import { CanonicalizeUnicodeLocaleId } from "./src/canonicalizer.js";
|
|
2
|
+
import { emitUnicodeLocaleId } from "./src/emitter.js";
|
|
3
|
+
import { parseUnicodeLocaleId } from "./src/parser.js";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* https://tc39.es/ecma402/#sec-canonicalizelocalelist
|
|
6
|
+
* @param locales
|
|
7
|
+
*/
|
|
8
8
|
function CanonicalizeLocaleList(locales) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return seen;
|
|
9
|
+
if (locales === undefined) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const seen = [];
|
|
13
|
+
if (typeof locales === "string") {
|
|
14
|
+
locales = [locales];
|
|
15
|
+
}
|
|
16
|
+
for (const locale of locales) {
|
|
17
|
+
const canonicalizedTag = emitUnicodeLocaleId(CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(locale)));
|
|
18
|
+
if (seen.indexOf(canonicalizedTag) < 0) {
|
|
19
|
+
seen.push(canonicalizedTag);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return seen;
|
|
24
23
|
}
|
|
25
24
|
export function getCanonicalLocales(locales) {
|
|
26
|
-
|
|
25
|
+
return CanonicalizeLocaleList(locales);
|
|
27
26
|
}
|
|
28
|
-
export * from
|
|
29
|
-
export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
27
|
+
export * from "./src/emitter.js";
|
|
28
|
+
export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId } from "./src/parser.js";
|
|
29
|
+
export * from "./src/types.js";
|
|
30
|
+
export * from "./src/likelySubtags.generated.js";
|
package/package.json
CHANGED
package/polyfill-force.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { getCanonicalLocales } from
|
|
2
|
-
if (typeof Intl ===
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
else if (typeof global !== 'undefined') {
|
|
10
|
-
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
11
|
-
Object.defineProperty(global, 'Intl', {
|
|
12
|
-
value: {},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
1
|
+
import { getCanonicalLocales } from "./index.js";
|
|
2
|
+
if (typeof Intl === "undefined") {
|
|
3
|
+
if (typeof window !== "undefined") {
|
|
4
|
+
Object.defineProperty(window, "Intl", { value: {} });
|
|
5
|
+
} else if (typeof global !== "undefined") {
|
|
6
|
+
// @ts-ignore we don't include @types/node so global isn't a thing
|
|
7
|
+
Object.defineProperty(global, "Intl", { value: {} });
|
|
8
|
+
}
|
|
15
9
|
}
|
|
16
|
-
Object.defineProperty(Intl,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
Object.defineProperty(Intl, "getCanonicalLocales", {
|
|
11
|
+
value: getCanonicalLocales,
|
|
12
|
+
writable: true,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
configurable: true
|
|
21
15
|
});
|