diff --git a/package.json b/package.json index 5c6fbc49fe..0639684950 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "session-desktop", "productName": "Session", "description": "Private messaging from your desktop", - "version": "1.14.0", + "version": "1.14.1", "license": "GPL-3.0", "author": { "name": "Oxen Labs", diff --git a/ts/util/i18n/shared.ts b/ts/util/i18n/shared.ts index 353c4c2984..cffdc3da7e 100644 --- a/ts/util/i18n/shared.ts +++ b/ts/util/i18n/shared.ts @@ -72,16 +72,38 @@ export function getBrowserLocale() { // supportedLocalesOf will throw if the locales has a '_' instead of a '-' in it. const userLocaleDashed = browserLocale.replaceAll('_', '-'); - const matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(userLocaleDashed); - - const mappingTo = matchingLocales?.[0] || 'en'; - - if (!mappedBrowserLocaleDisplayed) { - mappedBrowserLocaleDisplayed = true; - i18nLog(`userLocaleDashed: '${userLocaleDashed}', mapping to browser locale: ${mappingTo}`); + try { + let matchingLocales: Array = []; + try { + matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(userLocaleDashed); + } catch (innerError) { + // some users have a locale setup with a ':' in it. + // see https://github.com/oxen-io/session-desktop/issues/3221 + const semiColonIndex = userLocaleDashed.indexOf(':'); + if (semiColonIndex > -1) { + matchingLocales = Intl.DateTimeFormat.supportedLocalesOf( + userLocaleDashed.substring(0, semiColonIndex) + ); + } + } + + const mappingTo = matchingLocales?.[0] || 'en'; + + if (!mappedBrowserLocaleDisplayed) { + mappedBrowserLocaleDisplayed = true; + i18nLog(`userLocaleDashed: '${userLocaleDashed}', mapping to browser locale: ${mappingTo}`); + } + + 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'; } - - return mappingTo; } export function setInitialLocale(crowdinLocaleArg: CrowdinLocale, dictionary: LocalizerDictionary) {