From 4164ded4858db6ffee71e95a782bfb067ee9fcb1 Mon Sep 17 00:00:00 2001 From: hiro-nikaitou Date: Wed, 23 Sep 2026 05:51:27 -0400 Subject: [PATCH 1/2] feat(i18n): use the OS language by default Signed-off-by: hiro-nikaitou --- frontend/src/i18n/setup.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/i18n/setup.ts b/frontend/src/i18n/setup.ts index dc3a6074..d6a0330a 100644 --- a/frontend/src/i18n/setup.ts +++ b/frontend/src/i18n/setup.ts @@ -46,7 +46,10 @@ Object.entries(localeFiles).forEach(([path, module]) => { const getStoredLanguage = (): string => { try { const stored = localStorage.getItem('altsendme-language') - return stored || 'en' + const tag = (navigator.language || 'en').toLowerCase() + const keys = Object.keys(resources) + const pick = (t: string) => keys.find((k) => k.toLowerCase().startsWith(t)) + return stored || pick(tag) || pick(tag.slice(0, 2)) || 'en' } catch { return 'en' } From dcf5cfbd31b2cd813d7710bb550c056c5052d49a Mon Sep 17 00:00:00 2001 From: hiro-nikaitou Date: Wed, 23 Sep 2026 22:35:44 -0400 Subject: [PATCH 2/2] fix(i18n): keep locale detection when storage is unavailable Reading the saved language and reading `navigator.language` shared one try/catch, so a storage denial returned the fallback before the browser locale was ever consulted. Separate the two so storage only means "no saved choice". Signed-off-by: hiro-nikaitou --- frontend/src/i18n/setup.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/i18n/setup.ts b/frontend/src/i18n/setup.ts index d6a0330a..93e620e4 100644 --- a/frontend/src/i18n/setup.ts +++ b/frontend/src/i18n/setup.ts @@ -44,8 +44,14 @@ Object.entries(localeFiles).forEach(([path, module]) => { }) const getStoredLanguage = (): string => { + let stored: string | null = null + try { + stored = localStorage.getItem('altsendme-language') + } catch { + // Continue with browser-locale detection when storage is unavailable. + } + try { - const stored = localStorage.getItem('altsendme-language') const tag = (navigator.language || 'en').toLowerCase() const keys = Object.keys(resources) const pick = (t: string) => keys.find((k) => k.toLowerCase().startsWith(t))