fix: boot in the account's language when offline - #2146
Open
Cartoone9 wants to merge 1 commit into
Open
Conversation
The store boots from localStorage, but 'app_language' is only written on an explicit in-app choice; a language that lives in the account's server settings never reaches the device. A PWA cold start with no network then runs in English even though every online session ran in the user's language, the same stranding liketrek#1618 fixed for currency and units. loadSettings now mirrors the fetched language into its own key ('app_language_server'), and the boot chain falls back to it between the explicit choice and 'en'. A separate key on purpose: 'app_language' means an explicit choice, and the login page's detection chain must keep running for users who never made one.
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.
Small fix for something I hit using the PWA offline: a cold start with no network boots in English even though my account language is set. Offered in case the approach fits, happy to adjust if you'd prefer a different shape. Based on
dev.What happens
The store boots from
app_languagein localStorage, which is only written when a language is explicitly picked in Settings. A language that lives in the account's server settings never reaches the device, so an offline launch falls back toenuntil a fetch that cannot happen. It looks like the same stranding #1618 addressed for currency and units, with the language left out.The change
loadSettingsmirrors the fetched language into its own key (app_language_server), and the boot chain reads: explicit choice, then mirror, thenen.I kept it a separate key on purpose:
app_languagecurrently means "the user chose this", andhasStoredLanguage()gates the login page's browser-language detection on it. Mirroring into the same key would have silently disabled that detection after any successful settings load. If you'd rather fold them together anyway, or mirror somewhere else entirely, happy to rework it.Tests
SETTINGS-LANG-001: loadSettings mirrors the account language for the next launchSETTINGS-LANG-002: the mirror never claims to be an explicit choiceSETTINGS-LANG-003: a cold start with no explicit choice boots in the mirrored languageSETTINGS-LANG-004: an explicit in-app choice outranks the mirrorFull client suite passes.