@brightspace-ui/intl 3.25.0 → 3.25.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/lib/common.js +10 -2
- package/package.json +1 -1
package/lib/common.js
CHANGED
|
@@ -93,7 +93,7 @@ class DocumentLocaleSettings {
|
|
|
93
93
|
|
|
94
94
|
constructor() {
|
|
95
95
|
this._cache = new Map();
|
|
96
|
-
this._htmlElem =
|
|
96
|
+
this._htmlElem = document.documentElement;
|
|
97
97
|
this._listeners = [];
|
|
98
98
|
this._overrides = {};
|
|
99
99
|
this._observer = new MutationObserver(this._handleObserverChange.bind(this));
|
|
@@ -227,8 +227,16 @@ export function getDocumentLocaleSettings() {
|
|
|
227
227
|
return documentLocaleSettings;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
const localeRegEx = /[^a-zA-Z0-9-]/g;
|
|
231
|
+
|
|
230
232
|
function updateLocalNames() {
|
|
231
|
-
const
|
|
233
|
+
const possibleLocales = [documentLocaleSettings.language, navigator.language, defaultLocale].filter(l => l && !localeRegEx.test(l));
|
|
234
|
+
let localName;
|
|
235
|
+
try {
|
|
236
|
+
localName = new Intl.DisplayNames(possibleLocales, { type: 'language' });
|
|
237
|
+
} catch {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
232
240
|
supportedLocalesDetails.forEach(l => {
|
|
233
241
|
l.localName = localName.of(l.overrideCode || l.code);
|
|
234
242
|
});
|
package/package.json
CHANGED