Switch also the backend locale when changing the language via URL parameter#739
Switch also the backend locale when changing the language via URL parameter#739
Conversation
| async setUILanguage(lang) { | ||
| const proxy = await this.client.proxy(LANGUAGE_IFACE); | ||
| proxy.UILocale = lang; | ||
| } |
There was a problem hiding this comment.
well, there is also method to list UILanguages and it is useful for matching values. As e.g. czech is cs_CZ but in yast we use only cs locale. So there should be ideally some method that do matching of available locales and ones set in cockpit.
There was a problem hiding this comment.
This implementation is for setting the locale via ?lang= URL query parameter. This should be used by experts and the user is responsible for using the correct locale name. I think this is OK as the initial implementation, we can improve it later if needed.
And the UI selector should only offer supported values.
There was a problem hiding this comment.
OK, even if it does not work, I think we will find it soon ( as I am not sure if web UI locale will be the same )
Problem
Solution
Testing
Notes
Originally I implemented the backed switcher in the
L10nWrappercomponent 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.)