Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a hack for proper locale initialization #2017

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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