-
Notifications
You must be signed in to change notification settings - Fork 454
Windows | UI Language wrong if user preference != system default #976
Description
Issue
On the Windows platform, when the user language preference is different from the system default language preference, Mu assumes the system default one, instead of the user's.
Observed on Windows 10. Not sure about other releases.
Steps to reproduce
(assuming an English based installation, otherwise will vary)
-
Log in with an administrative user.
-
The general UI should be displayed in English (check the start menu, for example).
-
Go to "Settings" > "Time & Language" > "Region & Language".
-
Confirm that "Windows display language" is set to English.
-
Add a language, say "Français (France)" taking care in deactivating "Set as my Windows display language" during the process. This may take a little while.
-
When done, the language should be listed as "Language pack installed".
-
Confirm that "Windows display language" is still set to English.
-
Close the "Settings" window and sign out.
-
Log in as a different, non-administrative user.
-
The general UI should be displayed in English (check the start menu, for example).
-
Go to "Settings" > "Time & Language" > "Region & Language".
-
In my experiments, the admin-installed language isn't available yet. It needs to be "reinstalled" so repeat the procedure of installing "Français (France)", this time leaving the "Set as my Windows display language" active during the process -- for some reason, this needs an admin password (also, none of this works on my system if I don't do the language install as admin).
-
Confirm that "Windows display language" is set to "Français (France)" (set it, otherwise). Again, in my experience, I had to close the "Settings" and re-open it to get the option to be selectable.
-
Close the "Settings" window, sign out and sign back in.
-
The general UI should be displayed in French (check the start menu, for example), even though the default system language is still English.
Finally:
- Launch Mu
- The UI is presented in English instead of French.
Investigation
When faced with this, and after believing that Qt's QLocale would handle all of these troubles for us, as shared in #763 and implemented in #764, I quickly experimented with a REPL with the Mu Python environment as of the current master:
>>> from PyQt5.Qt import QLocale
>>> QLocale.system().name()
'en_US'
I then tried the previously used:
>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'cp1252')
How cool is this? Or frustrating?... :-)
I then browsed the QLocale API docs and found QLocale().uiLanguages() which seems promising:
>>> from PyQt5.Qt import QLocale
>>> QLocale().uiLanguages()
['fr-fr', 'en-US']
macOS
I tried it on macOS 10.14.6 where my Language settings are "English" but region is "Portugal", that gives me:
>>> from PyQt5.Qt import QLocale
>>> QLocale().uiLanguages()
['en-PT', 'pt-PT']
...which, I guess, kind of makes sense, even though 'en-PT' isn't a common language spec.
Ubuntu Linux
Then, on Ubuntu 18.04 LTS, with the UI language set to Portuguese:
>>> from PyQt5.Qt import QLocale
>>> QLocale().uiLanguages()
['pt-PT', 'en-US', 'en']
Parting Words
All in all this is a very tiny detail, but one that can be improved by using QLocale().uiLanguages(). The macOS solution might need some adjustments given the 'en-PT' I'm getting: I suppose other Language/Region combinations will produce similarly funny / non-matching language codes for the locales that Mu includes. But that doesn't feel difficult to handle.
This is it. Feedback welcome. :)