Do not crash on failure to fetch localization percentage
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user