Skip to content

Commit bce4bd4

Browse files
authored
Merge pull request #3225 from oxen-io/unstable
Session 1.14.1
2 parents 18862ab + e0d971b commit bce4bd4

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "session-desktop",
33
"productName": "Session",
44
"description": "Private messaging from your desktop",
5-
"version": "1.14.0",
5+
"version": "1.14.1",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Labs",

ts/util/i18n/shared.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,38 @@ export function getBrowserLocale() {
7272
// supportedLocalesOf will throw if the locales has a '_' instead of a '-' in it.
7373
const userLocaleDashed = browserLocale.replaceAll('_', '-');
7474

75-
const matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(userLocaleDashed);
76-
77-
const mappingTo = matchingLocales?.[0] || 'en';
78-
79-
if (!mappedBrowserLocaleDisplayed) {
80-
mappedBrowserLocaleDisplayed = true;
81-
i18nLog(`userLocaleDashed: '${userLocaleDashed}', mapping to browser locale: ${mappingTo}`);
75+
try {
76+
let matchingLocales: Array<string> = [];
77+
try {
78+
matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(userLocaleDashed);
79+
} catch (innerError) {
80+
// some users have a locale setup with a ':' in it.
81+
// see https://github.com/oxen-io/session-desktop/issues/3221
82+
const semiColonIndex = userLocaleDashed.indexOf(':');
83+
if (semiColonIndex > -1) {
84+
matchingLocales = Intl.DateTimeFormat.supportedLocalesOf(
85+
userLocaleDashed.substring(0, semiColonIndex)
86+
);
87+
}
88+
}
89+
90+
const mappingTo = matchingLocales?.[0] || 'en';
91+
92+
if (!mappedBrowserLocaleDisplayed) {
93+
mappedBrowserLocaleDisplayed = true;
94+
i18nLog(`userLocaleDashed: '${userLocaleDashed}', mapping to browser locale: ${mappingTo}`);
95+
}
96+
97+
return mappingTo;
98+
} catch (e) {
99+
if (!mappedBrowserLocaleDisplayed) {
100+
mappedBrowserLocaleDisplayed = true;
101+
i18nLog(
102+
`userLocaleDashed: '${userLocaleDashed}' was an invalid locale for supportedLocalesOf(). Falling back to 'en'. Error:${e.message} `
103+
);
104+
}
105+
return 'en';
82106
}
83-
84-
return mappingTo;
85107
}
86108

87109
export function setInitialLocale(crowdinLocaleArg: CrowdinLocale, dictionary: LocalizerDictionary) {

0 commit comments

Comments
 (0)