@brightspace-ui/intl 3.42.0 → 3.42.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.
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { defaultLocale, resolveSupportedLocale } from './supported.js';
|
|
1
2
|
import { getDocumentLocaleSettings } from '../common.js';
|
|
2
3
|
|
|
3
|
-
import { resolveSupportedLocale } from './supported.js';
|
|
4
|
-
|
|
5
4
|
const localeDataTarget = {};
|
|
6
5
|
|
|
7
6
|
// block deletions and existing property redefinitions
|
|
@@ -21,7 +20,7 @@ Object.defineProperty(localeDataTarget, 'finally', { value: (...args) => localeD
|
|
|
21
20
|
|
|
22
21
|
async function setLocaleData() {
|
|
23
22
|
if (currentLocale === documentLocaleSettings.language) return;
|
|
24
|
-
const resolvedLanguage = resolveSupportedLocale(documentLocaleSettings.language);
|
|
23
|
+
const resolvedLanguage = resolveSupportedLocale(documentLocaleSettings.language || documentLocaleSettings.fallbackLanguage || defaultLocale);
|
|
25
24
|
const newData = deepFreeze((await import(`./locales/${resolvedLanguage}.js`)).default);
|
|
26
25
|
|
|
27
26
|
Object.keys(newData).forEach(k => localeDataTarget[k] = newData[k]);
|
|
@@ -39,19 +39,21 @@ export const supportedLocales = supportedLocalesDetails.map(l => l.code);
|
|
|
39
39
|
export function resolveSupportedLocale(localeTags) {
|
|
40
40
|
localeTags = [].concat(localeTags);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if (localeTags.length) {
|
|
43
|
+
for (const localeTag of localeTags) {
|
|
44
|
+
const localeTagLower = localeTag.toLowerCase();
|
|
45
|
+
const locale = supportedLocalesDetails.find(l => [l.overrideCode, l.code].includes(localeTagLower));
|
|
46
|
+
if (locale) {
|
|
47
|
+
return locale.overrideCode || locale.source;
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
|
-
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
for (const localeTag of localeTags) {
|
|
52
|
+
const lang = localeTag.split('-')[0];
|
|
53
|
+
const locale = supportedLocalesDetails.find(l => l.source === lang);
|
|
54
|
+
if (locale) {
|
|
55
|
+
return locale.overrideCode || locale.source;
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
return defaultLocale;
|
package/package.json
CHANGED