mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.41k stars 435 forks source link

Status bar language not updated after change in user preference #1849

Open aroberge opened 3 years ago

aroberge commented 3 years ago

What were you trying to do?

Change the language for the UI

What steps did you take to trigger the issue?

What did you expect to happen?

That the message would be shown in the newly selected language

What actually happened?

It was not: image

Operating System Version

Windows 10

Mu Version

1.1.0.beta.6

Other Info

This was originally mentioned in a comment for issue #976

Editor Log

No response

ntoll commented 3 years ago

Just to confirm, you had changed to English :gb: from French :fr: but the message of the day was in French (when you were expecting it in English)..?

aroberge commented 3 years ago

@ntoll Correct: by default, Mu is in French on my system. After I changed to English and restarted, the menu was correctly changed to English but the message of the day (which I had never noticed before ... perhaps it is new?...) was not translated.

devdanzin commented 2 years ago

Confirmed. I think it comes from the fact the MOTD list is populated/localized before we do a i18n.set_language(self.user_locale). Then we pick a MOTD to display: self.show_status_message(random.choice(MOTD), 10)

It seems to be fixable by having a non-localized MOTD list, then localizing the selected entry:

-        self.show_status_message(random.choice(MOTD), 10)       
+        self.show_status_message(_(random.choice(MOTD)), 10)    

Working on a test and PR.

devdanzin commented 2 years ago

I have two different simple fixes ready for this issue and can't decide which one is better. Indeed, it comes from building MOTD before figuring out user_locale.

Option 1, it can be solved by localizing a single entry of the MOTD list after user_locale is set (as described in previous comment). It removes _() (gettext) from a lot of messages, I fear it might be detrimental for the localization workflow.

Option 2, we create a simple get_MOTD function so _() (gettext) remains in place but is only evaluated after user_locale is set.

Maybe I should just create two PRs and we can decide, with code to reference?

xbecas commented 2 years ago

Just to add that there are at least two other "places" where this happens:

The Modes Dialog and the comment on a blank file - both visible on the following image, where Portuguese sentences are shown with "English" explicitly chosen from language list.

PS: my W10 OS is in Portuguese.

image