1
0

locale/i18n: get default language and set it as early as possible

TODO elaborate xxxxx
This commit is contained in:
SomberNight
2023-05-05 17:00:18 +00:00
parent 9c47144418
commit a0c43573ab
7 changed files with 63 additions and 41 deletions

View File

@@ -384,14 +384,22 @@ def main():
sys.exit(1)
config = SimpleConfig(config_options)
cmdname = config.get('cmd')
# set language as early as possible
# Note: we are already too late for strings that are declared in the global scope
# of an already imported module. However, the GUI and the plugins at least have
# not been imported yet.
# Note: it is ok to call set_language() again later. E.g. the Qt GUI has additional
# tools to figure out the default language so it will get called again there.
set_language(config.get('language'))
# not been imported yet. (see #4621)
# Note: it is ok to call set_language() again later, but note that any call only applies
# to not-yet-evaluated strings.
if cmdname == 'gui':
from electrum.gui.default_lang import get_default_language
gui_name = config.get('gui', 'qt')
lang = config.get('language')
if not lang:
lang = get_default_language(gui_name=gui_name)
_logger.info(f"get_default_language: detected default as {lang=!r}")
set_language(lang)
if config.get('testnet'):
constants.set_testnet()
@@ -402,8 +410,6 @@ def main():
elif config.get('signet'):
constants.set_signet()
cmdname = config.get('cmd')
if cmdname == 'daemon' and config.get("detach"):
# detect lockfile.
# This is not as good as get_file_descriptor, but that would require the asyncio loop