Default to English on unsupported system language Fix #976

- Add check for supported language to system locale detection
- Fall-back to English when not a supported locale
This commit is contained in:
Andrew Senetar 2022-03-12 04:33:27 -06:00
parent 9e4b41feb5
commit 4b2fbe87ea
Signed by: arsenetar
GPG Key ID: C63300DCE48AB2F1
1 changed files with 7 additions and 5 deletions

View File

@ -150,11 +150,13 @@ def install_gettext_trans_under_qt(base_folder, lang=None):
if not lang: if not lang:
lang = str(QLocale.system().name())[:2] lang = str(QLocale.system().name())[:2]
localename = get_locale_name(lang) localename = get_locale_name(lang)
if localename is not None: if localename is None:
try: lang = "en"
locale.setlocale(locale.LC_ALL, localename) localename = get_locale_name(lang)
except locale.Error: try:
logging.warning("Couldn't set locale %s", localename) locale.setlocale(locale.LC_ALL, localename)
except locale.Error:
logging.warning("Couldn't set locale %s", localename)
qmname = "qt_%s" % lang qmname = "qt_%s" % lang
if ISLINUX: if ISLINUX:
# Under linux, a full Qt installation is already available in the system, we didn't bundle # Under linux, a full Qt installation is already available in the system, we didn't bundle