Repository navigation
fix(i18n): apply each user's language and keep the picker in step - #339
Merged
Merged
Conversation
On multi-user installs the translator boots before the user is restored, so a saved interface language was never read. Apply it once the middleware knows the user, and reload the preferences page when it changes. Values persisted from a request went to the global row, which a user's reads never see, so ?filterlang= was lost and one user's language leaked into the shared defaults. Save them per user. Creating a language, opening a text and reviewing a language now also update the picker.
cy.request() fails the test on a refused connection, so the check meant to skip the spec failed it instead. Probe AnkiConnect from a Node task.
The call ran before the request was validated, so a review that was about to redirect could still switch the language, and without a database it stopped the page before the rest of its work. Move it to just before rendering, using the language the review resolved so reviews started from a text are covered too.
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.
Two settings silently did nothing on multi-user installs, which is what production runs. The suite mostly runs single-user, so neither showed up.
Interface language
TranslatorServiceProvider::boot()runs before the middleware restores the user, so it only saw the global default. Three production users have chosen a language that was never applied.UserLocale::apply()runs inAuthMiddlewareandAdminMiddlewareonce the user is known. A user's own choice beats a leftoverlwt_langcookie; a user with no choice keeps what boot settled on.app_languagechanges, since it is already rendered in the old language.Language picker
getStringWithDb()andgetIntWithDb()saved throughSettings::save(), which writes the global row that a user's reads never see. So?filterlang=was lost, and one user's value landed in the shared defaults.savePerUser(), as doesformatSetDefault(). Remembered sort orders are fixed by the same change.CurrentLanguage::follow()moves the picker when a language is created, a text is opened, or a language is reviewed. It only accepts the user's own languages.Behaviour to expect after deploying
Also
24-anki-livefailed without Anki instead of skipping as its header says, becausecy.request()fails the test on a refused connection. It now probes AnkiConnect from a Node task.Testing
?filterlang=, reader and review;deandfaapplied, withdir="rtl"forfa.24-anki-live. After the fix, that spec skips both tests without Anki. The full suite was not rerun after that change.