Browse Source

i18n: simplify language default. only translate string if using GUI.

master
SomberNight 2 years ago
parent
commit
0e5a1380ca
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 13
      electrum/i18n.py
  2. 2
      run_electrum

13
electrum/i18n.py

@ -33,16 +33,9 @@ from .logging import get_logger
_logger = get_logger(__name__)
LOCALE_DIR = os.path.join(os.path.dirname(__file__), 'locale')
# set initial default language, based on OS-locale
# FIXME some module-level strings might get translated using this language, before
# any user-provided custom language (in config) can get set.
language = gettext.translation('electrum', LOCALE_DIR, fallback=True)
try:
_lang = language.info().get('language', None)
except Exception as e:
_logger.info(f"gettext setting initial language to ?? (error: {e!r})")
else:
_logger.info(f"gettext setting initial language to {_lang!r}")
# Set initial default language to None. i.e. translations explicitly disabled.
# The main script or GUIs can call set_language to enable translations.
language = gettext.translation('electrum', fallback=True, class_=gettext.NullTranslations)
# note: do not use old-style (%) formatting inside translations,

2
run_electrum

@ -367,6 +367,8 @@ def main():
# 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.
# Note: the CLI is intentionally always non-localized.
# Note: Some unit tests might rely on the default non-localized strings.
if cmdname == 'gui':
gui_name = config.GUI_NAME
lang = config.LOCALIZATION_LANGUAGE

Loading…
Cancel
Save