Ensure that languages that are set are actually supported

This commit is contained in:
blitzmann
2020-06-29 21:10:10 -04:00
parent 732634fefa
commit c242a18a34
3 changed files with 8 additions and 3 deletions

View File

@@ -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():

View File

@@ -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)

View File

@@ -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