Show progress of translations

This commit is contained in:
Ryan Holmes
2020-07-25 17:39:28 -04:00
parent bec9eb2224
commit 469c255bbf
2 changed files with 29 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ import os.path
import urllib.request
import urllib.error
import urllib.parse
import json
from collections import namedtuple
import wx
@@ -536,20 +537,24 @@ class GraphSettings:
def set(self, type, value):
self.settings[type] = value
Locale = namedtuple('Locale', ['wxLocale', 'eosLang'])
class LocaleSettings:
_instance = None
DEFAULT = "en_US"
DEFAULT = "en_US"
defaults = {
'locale': DEFAULT,
'eos_locale': 'Auto' # flag for "Default" which is the same as the locale or, if not available, English
}
@classmethod
def supported_langauges(cls):
"""Requires the application to be initialized, otherwise wx.Translation isn't set."""
return {x: wx.Locale.FindLanguageInfo(x) for x in wx.Translations.Get().GetAvailableTranslations(config.CATALOG)}
def __init__(self):
self.settings = SettingsProvider.getInstance().getSettings('localeSettings', self.defaults)
try:
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
@classmethod
def getInstance(cls):
@@ -557,8 +562,17 @@ class LocaleSettings:
cls._instance = LocaleSettings()
return cls._instance
def __init__(self):
self.settings = SettingsProvider.getInstance().getSettings('localeSettings', self.defaults)
def get_progress(self, lang):
if self.progress_data is None:
return None
if lang == self.defaults['locale']:
return None
return self.progress_data[lang]
@classmethod
def supported_langauges(cls):
"""Requires the application to be initialized, otherwise wx.Translation isn't set."""
return {x: wx.Locale.FindLanguageInfo(x) for x in wx.Translations.Get().GetAvailableTranslations(config.CATALOG)}
def get(self, key):
"""gets the raw value fo the setting"""