Repository navigation
fix(i18n): persist manual language selection across restarts - #544
Merged
Merged
Conversation
getStoredLocale() read localStorage['lang'], which nothing ever wrote, so a language picked in settings silently reverted to OS auto-detection on the next launch (pre-existing, affecting zhCN as well). Now it validates the value and falls back to the pinia-persisted app.languageType, so existing choices take effect retroactively and a corrupted blob degrades gracefully to auto-detection. Also consolidates the zh-TW parity test into tests/lang/parity.test.ts (two-direction key parity + placeholder checks parametrized over both locales) and covers the new locale auto-detection and persistence fallback paths in tests/lang/index.test.ts.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #544 +/- ##
==========================================
+ Coverage 71.88% 71.89% +0.01%
==========================================
Files 169 169
Lines 29735 29743 +8
Branches 1479 1482 +3
==========================================
+ Hits 21376 21385 +9
Misses 7909 7909
+ Partials 450 449 -1
🚀 New features to boost your workflow:
|
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.
Follow-up on the review of #542 (zh-TW).
Fix: language choice was never persisted
getStoredLocale()readlocalStorage['lang'], which nothing in the codebase ever wrote — so a language picked in settings silently reverted to OS auto-detection on the next launch. This was pre-existing (affected zhCN too); for zh-TW users it was masked because auto-detection now happens to resolve tozhTW.getStoredLocale()now:langvalue (previously cast unchecked),app.languageType(pinia-plugin-persistedstate default key = store id, verified from the plugin source), so existing users' past choices take effect retroactively — no picker change needed,Tests
tests/lang/zhTW.test.tsmerged intotests/lang/parity.test.ts: key parity + placeholder checks are now parametrized overzhCN/zhTW, and both get two-direction assertions (en→locale and locale→en no-extra-keys) — stronger than the previous zhCN one-direction check. Adding a future locale is one array entry.tests/lang/index.test.tsextended with the behavior feat(i18n): add Traditional Chinese (zh-TW) #542 introduced but didn't cover:it.eachoverzh-TW/zh-Hant-TW/zh-Hant/zh-HK/zh-MO→ cn, barezh/en-US→ en, plus the three persistence-fallback paths (validzhTW, invalid value, corrupted JSON).Verification
npx jest— 70 suites / 1983 tests passnpx tsc --noEmit— cleannpx eslinton changed files — clean