fix: add missing English check in detectLocale()#12064
Open
andybergon wants to merge 1 commit intoanomalyco:devfrom
Open
fix: add missing English check in detectLocale()#12064andybergon wants to merge 1 commit intoanomalyco:devfrom
andybergon wants to merge 1 commit intoanomalyco:devfrom
Conversation
The detectLocale() function checks for zh, ko, de, es, fr, da, ja, pl, ru, ar, no, pt, and th — but not en. English entries in the browser's language list are silently skipped, causing the first non-English supported language to be selected instead. For example, with browser languages [en-IE, en-US, en-GB, en, it, es], all English entries fall through and Spanish (the least preferred) is picked. Fixes anomalyco#12063 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
Author
|
I encountered this bug, would love to see a fix. |
Author
|
hey @rekram1-node, just bumping this. CI is green and there's some interest from others hitting this bug. also noting that #9998 fixes the same root cause but only for the web app, while this one covers the desktop path too. happy to adjust anything if needed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
encheck todetectLocale()in the web app and desktop appProblem
detectLocale()iterates throughnavigator.languagesand checks forzh,ko,de,es,fr, etc. — but noten. Thereturn "en"default at the end only triggers if no supported language is found. If a user has[en-IE, en-US, en-GB, en, it, es], all English entries fall through andes(Spanish, the least preferred) is selected.Fix
Add
if (language.toLowerCase().startsWith("en")) return "en"as the first check in the loop, in both affected files:packages/app/src/context/language.tsx(web app)packages/desktop/src/i18n/index.ts(desktop app)The enterprise package (
packages/enterprise/src/entry-server.tsxandapp.tsx) already checks forenexplicitly and is not affected.Fixes #12063