Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/web/src/hooks/use-locale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,24 @@ async function bootstrapLocale(
// flight, their selection is the source of truth — don't overwrite it.
// Issue #759: on Windows zh-CN systems, the bootstrap was reverting a
// user-selected English back to Chinese on the welcome screen.
// Issue #448: the welcome page language switcher does not change UI language
// because the bootstrap was overwriting the user's selection.
if (userInteractedRef.current) {
return;
}

// If the user has manually selected a language via localStorage, use that
// as the source of truth and don't overwrite it with the server value.
try {
const manualSelection = localStorage.getItem(STORAGE_KEY);
if (manualSelection === "en" || manualSelection === "zh") {
// User has manually selected a language, respect their choice
return;
Comment on lines +127 to +129
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve server locale sync when localStorage has value

Returning immediately when localStorage contains "en"/"zh" skips the later syncDesktopLocale(localCandidate) path, so a client can get stuck with an unsynced controller locale. A concrete case is: first boot while getApiInternalDesktopPreferences() fails (or returns locale: null) writes local storage only, then on later boots this new early return prevents ever backfilling the controller preference; backend flows that read getDesktopLocale() (defaulting to "en" when unset) can continue emitting English while the UI remains Chinese.

Useful? React with 👍 / 👎.

}
} catch {
/* ignore */
}

if (storedLocale === "en" || storedLocale === "zh-CN") {
const nextLocale = storedLocale === "zh-CN" ? "zh" : "en";
await i18n.changeLanguage(nextLocale);
Expand Down