@shoelace-style/localize 3.1.1 → 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/CHANGELOG.md +4 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -51,7 +51,7 @@ export class LocalizeController {
|
|
|
51
51
|
}
|
|
52
52
|
getTranslationData(lang) {
|
|
53
53
|
var _a, _b;
|
|
54
|
-
const locale = new Intl.Locale(lang);
|
|
54
|
+
const locale = new Intl.Locale(lang.replace(/_/g, '-'));
|
|
55
55
|
const language = locale === null || locale === void 0 ? void 0 : locale.language.toLowerCase();
|
|
56
56
|
const region = (_b = (_a = locale === null || locale === void 0 ? void 0 : locale.region) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
57
57
|
const primary = translations.get(`${language}-${region}`);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -117,7 +117,9 @@ export class LocalizeController<UserTranslation extends Translation = DefaultTra
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
private getTranslationData(lang: string) {
|
|
120
|
-
|
|
120
|
+
// Convert "en_US" to "en-US". Note that both underscores and dashes are allowed per spec, but underscores result in
|
|
121
|
+
// a RangeError by the call to `new Intl.Locale()`. See: https://unicode.org/reports/tr35/#unicode-locale-identifier
|
|
122
|
+
const locale = new Intl.Locale(lang.replace(/_/g, '-'));
|
|
121
123
|
const language = locale?.language.toLowerCase();
|
|
122
124
|
const region = locale?.region?.toLowerCase() ?? '';
|
|
123
125
|
const primary = <UserTranslation>translations.get(`${language}-${region}`);
|