Cant pass None to QLocale any more. Will result in loading "C" locale. (#583)

This commit is contained in:
Manu 2020-08-14 16:13:11 +08:00 committed by GitHub
parent 10c9b9acc1
commit ec374953e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -54,7 +54,13 @@ def init_translations(app):
application = app
translator = QTranslator() if trans_scale == 100 else VortaTranslator()
locale = QLocale(os.environ.get('LANG', None))
# Use LANG var if set, else let Qt detect it.
env_lang = os.environ.get('LANG', False)
if env_lang:
locale = QLocale(env_lang)
else:
locale = QLocale()
qm_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'qm'))
ui_langs = locale.uiLanguages()
succeeded = translator.load(locale, 'vorta', prefix='.', directory=qm_path) # e.g. vorta/i18n/qm/vorta.de_DE.qm