From 4b2fbe87ea0e5d68f37519d6ab9d170353fa03af Mon Sep 17 00:00:00 2001 From: Andrew Senetar Date: Sat, 12 Mar 2022 04:33:27 -0600 Subject: [PATCH] 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 --- hscommon/trans.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hscommon/trans.py b/hscommon/trans.py index c94ba9e8..69bff565 100644 --- a/hscommon/trans.py +++ b/hscommon/trans.py @@ -150,11 +150,13 @@ def install_gettext_trans_under_qt(base_folder, lang=None): if not lang: lang = str(QLocale.system().name())[:2] localename = get_locale_name(lang) - if localename is not None: - try: - locale.setlocale(locale.LC_ALL, localename) - except locale.Error: - logging.warning("Couldn't set locale %s", localename) + if localename is None: + lang = "en" + localename = get_locale_name(lang) + try: + locale.setlocale(locale.LC_ALL, localename) + except locale.Error: + logging.warning("Couldn't set locale %s", localename) qmname = "qt_%s" % lang if ISLINUX: # Under linux, a full Qt installation is already available in the system, we didn't bundle