Skip to content

Commit 9a907af

Browse files
Provide a hack for proper locale initialization.
Fix mu-editor#2008.
1 parent 5a5d772 commit 9a907af

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

mu/app.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,25 @@
4242
from . import i18n
4343
from .virtual_environment import venv, logger as vlogger
4444
from . import __version__
45+
from .resources import load_icon, load_movie, load_pixmap
46+
from .interface.themes import NIGHT_STYLE, DAY_STYLE, CONTRAST_STYLE
47+
48+
# HACK: Ensure that i18n settings are present before any gettext
49+
# functions are called.
50+
from . import settings
51+
#
52+
# Load settings from known locations and register them for
53+
# autosave
54+
#
55+
settings.init()
56+
old_session = settings.session
57+
if "locale" in old_session:
58+
user_locale = old_session["locale"].strip()
59+
if user_locale:
60+
i18n.set_language(user_locale)
61+
4562
from .logic import Editor, LOG_FILE, LOG_DIR, ENCODING
4663
from .interface import Window
47-
from .resources import load_icon, load_movie, load_pixmap
4864
from .modes import (
4965
PythonMode,
5066
CircuitPythonMode,
@@ -57,8 +73,6 @@
5773
LegoMode,
5874
PicoMode,
5975
)
60-
from .interface.themes import NIGHT_STYLE, DAY_STYLE, CONTRAST_STYLE
61-
from . import settings
6276

6377

6478
class AnimatedSplash(QSplashScreen):
@@ -272,11 +286,8 @@ def run():
272286
logging.info("Python path: {}".format(sys.path))
273287
logging.info("Language code: {}".format(i18n.language_code))
274288

275-
#
276-
# Load settings from known locations and register them for
277-
# autosave
278-
#
279-
settings.init()
289+
# Not loading settings here because the same has been done at the top of
290+
# the script
280291

281292
# Images (such as toolbar icons) aren't scaled nicely on retina/4k displays
282293
# unless this flag is set

0 commit comments

Comments
 (0)