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

@@ -33,9 +33,6 @@ if TYPE_CHECKING:
from .qeapp import ElectrumQmlApplication, Exception_Hook
if 'ANDROID_DATA' in os.environ:
from jnius import autoclass, cast
jLocale = autoclass("java.util.Locale")
class ElectrumTranslator(QTranslator):
def __init__(self, parent=None):
@@ -51,12 +48,6 @@ class ElectrumGui(BaseElectrumGui, Logger):
BaseElectrumGui.__init__(self, config=config, daemon=daemon, plugins=plugins)
Logger.__init__(self)
lang = config.get('language','')
if not lang:
lang = self.get_default_language()
self.logger.info(f'setting language {lang}')
set_language(lang)
# uncomment to debug plugin and import tracing
# os.environ['QML_IMPORT_TRACE'] = '1'
# os.environ['QT_DEBUG_PLUGINS'] = '1'
@@ -119,12 +110,3 @@ class ElectrumGui(BaseElectrumGui, Logger):
def stop(self):
self.logger.info('closing GUI')
self.app.quit()
def get_default_language(self):
# On Android QLocale does not return the system locale
try:
name = str(jLocale.getDefault().toString())
except Exception:
name = QLocale.system().name()
self.logger.info(f'System default locale: {name}')
return name if name in languages else 'en_GB'