-
Notifications
You must be signed in to change notification settings - Fork 235
fix: 欢迎页语言切换器无效 #448 #1148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: 欢迎页语言切换器无效 #448 #1148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: More explicit catch for debugging, e.g. |
||
| // 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Returning immediately when Useful? React with 👍 / 👎. |
||
| } | ||
| } catch { | ||
| /* ignore */ | ||
| } | ||
|
|
||
| if (storedLocale === "en" || storedLocale === "zh-CN") { | ||
| const nextLocale = storedLocale === "zh-CN" ? "zh" : "en"; | ||
| await i18n.changeLanguage(nextLocale); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a JSDoc comment here explaining this localStorage check fixes #448 by preventing bootstrap from overwriting user manual selection. Helps future readers.