Switch also the backend locale when changing the language via URL parameter #739
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.
Problem
Solution
Testing
Notes
Originally I implemented the backed switcher in the
L10nWrapper
component which changes the language for the frontend.But the problem is that switching the backend language requires DBus access which displays a message "Loading installation environment" while initializing. That message would be untranslated and if the DBus initialization failed it would display and an untranslated error as well.
For that reason I have split the language switching into two parts. First it changes the frontend language and reloads the page so it displays the translated message during the DBus initialization. Then it changes the backend language and reloads again.
Two reloads might look a bit too much but the first one is very quick (~200ms in production), the second reload takes more time (1-2s) but at least it displays a translated progress message.
(This is valid for the language switching using the URL parameter, when implementing the language selection in the UI one reload should be enough.)