From c242a18a34476e144d94ee467dddf8919531adf5 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Mon, 29 Jun 2020 21:10:10 -0400 Subject: [PATCH] Ensure that languages that are set are actually supported --- config.py | 4 +++- eos/config.py | 2 +- service/settings.py | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 78848ae9a..fd3f5d626 100644 --- a/config.py +++ b/config.py @@ -190,7 +190,9 @@ def defPaths(customSavePath=None): from service.settings import EOSSettings, LocaleSettings eos.config.settings = EOSSettings.getInstance().EOSSettings # this is kind of confusing, but whatever - language = language or LocaleSettings.getInstance().get('locale') + # set langauge + localeSettings = LocaleSettings.getInstance() + language = language if language in localeSettings.supported_langauges else localeSettings.get('locale') eos.config.set_lang(language) def defLogging(): diff --git a/eos/config.py b/eos/config.py index a1a16fcef..ef2160f5d 100644 --- a/eos/config.py +++ b/eos/config.py @@ -29,7 +29,7 @@ translation_mapping = { def set_lang(i18n_lang): global lang - lang = translation_mapping.get(i18n_lang, translation_mapping.get("en-US")) + lang = translation_mapping.get(i18n_lang, translation_mapping.get("en_US")) pyfalog.debug("Gamedata connection string: {0}", gamedata_connectionstring) diff --git a/service/settings.py b/service/settings.py index b12a4d188..8fa80d677 100644 --- a/service/settings.py +++ b/service/settings.py @@ -538,6 +538,7 @@ class GraphSettings: class LocaleSettings: _instance = None + DEFAULT = "en_US" supported_langauges = { "en_US": wx.LANGUAGE_ENGLISH_US, @@ -554,7 +555,7 @@ class LocaleSettings: def __init__(self): defaults = { - 'locale': "en_US" + 'locale': self.DEFAULT } self.settings = SettingsProvider.getInstance().getSettings('localeSettings', defaults) @@ -562,4 +563,6 @@ class LocaleSettings: return self.settings[key] def set(self, key, value): + if key == 'locale' and value not in self.supported_langauges: + self.settings[key] = self.DEFAULT self.settings[key] = value