-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: store language code #2481
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
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| const langMap = { | ||
| "en-us": { | ||
| name: "English", | ||
| async strings() { | ||
|
|
@@ -190,9 +190,10 @@ | |
| export default { | ||
| async set(code) { | ||
| code = code?.toLowerCase(); | ||
| const lang = langMap[code] || langMap["en-us"]; | ||
| const lang = langMap[code] || langMap[code = "en-us"]; | ||
| const strings = await lang.strings(); | ||
| window.strings = strings.default; | ||
| window.localStorage["language"] = code; | ||
|
Contributor
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.
When storage is unavailable or throws, this new write rejects after
Comment on lines
+193
to
+196
Contributor
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.
For an unsupported input such as a fresh-install |
||
| }, | ||
| list: Object.keys(langMap).map((code) => [code, langMap[code].name]), | ||
| getName(code) { | ||
|
|
||
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.
When
settings.applyLangSetting()fireslang.set(value)without awaiting it, two quick language changes can resolve out of order. The olderlang.strings()import can finish last and this line then persists the stale code, so the next startup can restore a language different from the user's latest selection.