Skip to content

Commit

Permalink
Provide a hack for proper locale initialization.
Browse files Browse the repository at this point in the history
Fix #2008.
  • Loading branch information
CSharperMantle committed Jan 31, 2022
1 parent 5a5d772 commit 9a907af
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions mu/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,25 @@
from . import i18n
from .virtual_environment import venv, logger as vlogger
from . import __version__
from .resources import load_icon, load_movie, load_pixmap
from .interface.themes import NIGHT_STYLE, DAY_STYLE, CONTRAST_STYLE

# HACK: Ensure that i18n settings are present before any gettext
# functions are called.
from . import settings
#
# Load settings from known locations and register them for
# autosave
#
settings.init()
old_session = settings.session
if "locale" in old_session:
user_locale = old_session["locale"].strip()
if user_locale:
i18n.set_language(user_locale)

from .logic import Editor, LOG_FILE, LOG_DIR, ENCODING
from .interface import Window
from .resources import load_icon, load_movie, load_pixmap
from .modes import (
PythonMode,
CircuitPythonMode,
Expand All @@ -57,8 +73,6 @@
LegoMode,
PicoMode,
)
from .interface.themes import NIGHT_STYLE, DAY_STYLE, CONTRAST_STYLE
from . import settings


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

#
# Load settings from known locations and register them for
# autosave
#
settings.init()
# Not loading settings here because the same has been done at the top of
# the script

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

0 comments on commit 9a907af

Please sign in to comment.