Do not crash on failure to fetch localization percentage

This commit is contained in:
DarkPhoenix
2023-12-05 15:31:18 +06:00
parent c49a914584
commit cc0d6465d6
2 changed files with 6 additions and 6 deletions

View File

@@ -559,7 +559,7 @@ class LocaleSettings:
with open(os.path.join(config.pyfaPath, 'locale', 'progress.json'), "r") as f:
self.progress_data = json.load(f)
except FileNotFoundError:
self.progress_data = None
self.progress_data = {}
@classmethod
def getInstance(cls):
@@ -568,14 +568,14 @@ class LocaleSettings:
return cls._instance
def get_progress(self, lang):
if self.progress_data is None:
if not self.progress_data:
return None
if lang == self.defaults['locale']:
return None
return self.progress_data[lang]
return self.progress_data.get(lang)
@classmethod
def supported_langauges(cls):
def supported_languages(cls):
"""Requires the application to be initialized, otherwise wx.Translation isn't set."""
pyfalog.info(f'using "{config.CATALOG}" to fetch languages, relatively base path "{os.getcwd()}"')
return {x: wx.Locale.FindLanguageInfo(x) for x in wx.Translations.Get().GetAvailableTranslations(config.CATALOG)}
@@ -590,6 +590,6 @@ class LocaleSettings:
return val if val != self.defaults['eos_locale'] else self.settings['locale'].split("_")[0]
def set(self, key, value):
if key == 'locale' and value not in self.supported_langauges():
if key == 'locale' and value not in self.supported_languages():
self.settings[key] = self.DEFAULT
self.settings[key] = value