|
|
|
@ -72,6 +72,7 @@ export function getBrowserLocale() {
|
|
|
|
|
// supportedLocalesOf will throw if the locales has a '_' instead of a '-' in it.
|
|
|
|
|
const userLocaleDashed = browserLocale.replaceAll('_', '-');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(userLocaleDashed);
|
|
|
|
|
|
|
|
|
|
const mappingTo = matchingLocales?.[0] || 'en';
|
|
|
|
@ -82,6 +83,15 @@ export function getBrowserLocale() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mappingTo;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (!mappedBrowserLocaleDisplayed) {
|
|
|
|
|
mappedBrowserLocaleDisplayed = true;
|
|
|
|
|
i18nLog(
|
|
|
|
|
`userLocaleDashed: '${userLocaleDashed}' was an invalid locale for supportedLocalesOf(). Falling back to 'en'. Error:${e.message} `
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return 'en';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setInitialLocale(crowdinLocaleArg: CrowdinLocale, dictionary: LocalizerDictionary) {
|
|
|
|
|