feat(i18n): use the OS language by default - #327
hiro-nikaitou wants to merge 2 commits into
Conversation
Signed-off-by: hiro-nikaitou <vieteviete@proton.me>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughWhen no language is stored, ChangesLocale Selection
Priority: ⬇️ Low Change: Feature Merge Risk: ⚪ Minimal · up to The language fallback is ready to merge after normal checks. 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 977009d1-9ca3-49ab-8dea-f5e3362e2698
📒 Files selected for processing (1)
frontend/src/i18n/setup.ts
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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 <vieteviete@proton.me>
|
Applied in dcf5cfb, following the suggestion: the storage read and the locale lookup no longer share one try/catch, so a storage denial leaves
|
Description
With no saved choice the UI language was hardcoded to English, so a first run on a German (or Portuguese, Japanese, …) system came up in English even though the translation ships.
getStoredLanguage()now falls back tonavigator.language, matched case-insensitively against the shipped locales: the full tag wins first (zh-TWstays Traditional), otherwise the two-letter language prefix is used (pt-PT→pt-BR,de-AT→de), and an unmatched language still ends on English.A choice made in the language switcher keeps winning, and the detected language is not written to storage, so the app keeps following the system language until the user picks one explicitly.
Scope notes: only
navigator.language(the top OS/browser preference, which is what WebView2 and Android WebView report from the system) is consulted — not the secondarynavigator.languageslist.nb/nn(Bokmål/Nynorsk) still falls back to English because only anolocale ships, and azh-HK/zh-Hanttag resolves throughzhtozh-CN. Happy to extend the mapping if you want those covered.Verification
pnpm lint(biome lint: 350 files, no fixes applied +tsc --noEmit --skipLibCheck): exit 0pnpm test:lib:# tests 151 / # pass 151 / # fail 0, exit 0 (same on the unpatched tree)pnpm exec biome format frontend/src/i18n/setup.ts:No fixes applied, exit 0frontend/src/i18n/setup.tswas built through this repo's ownvite.config.ts(SSR build) and imported once per case with a stubbednavigator/localStorage. After the patch 11/11 cases pass —de→de,pt-PT→pt-BR,zh-TW→zh-TW,zh→zh-CN,en-US→en,fr-FR→fr,ja→ja,JA→ja,nl-NL→en(not shipped),nb-NO→en, and a savedjastill winning over systemde-DE. The identical script before the patch passes 4/11 (every case that should follow the system language resolved toen).Not covered: I did not run the desktop/web/Android UI on a non-English system.
Checklist
type(scope): description)pnpm lintbefore raising this PRpnpm formaton the touched file (biome format, no Rust files touched)Disclosure: this change was prepared with AI assistance.