Show progress of translations
This commit is contained in:
@@ -102,9 +102,14 @@ class PFGeneralPref(PreferenceView):
|
|||||||
self.stLangLabel.Wrap(-1)
|
self.stLangLabel.Wrap(-1)
|
||||||
langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
|
langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
|
|
||||||
self.langChoices = sorted([v for x, v in LocaleSettings.supported_langauges().items()], key=lambda x: x.Description)
|
self.langChoices = sorted([langInfo for lang, langInfo in LocaleSettings.supported_langauges().items()], key=lambda x: x.Description)
|
||||||
|
|
||||||
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [x.Description for x in self.langChoices], 0)
|
def langDisplay(langInfo):
|
||||||
|
progress = self.localeSettings.get_progress(langInfo.CanonicalName)
|
||||||
|
progress_display = (" ({}%)".format(progress['translated_progress']) if progress is not None else "")
|
||||||
|
return langInfo.Description + progress_display
|
||||||
|
|
||||||
|
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [langDisplay(x) for x in self.langChoices], 0)
|
||||||
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)
|
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)
|
||||||
|
|
||||||
selectedIndex = self.langChoices.index(next((x for x in self.langChoices if x.CanonicalName == self.localeSettings.get('locale')), None))
|
selectedIndex = self.langChoices.index(next((x for x in self.langChoices if x.CanonicalName == self.localeSettings.get('locale')), None))
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import os.path
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
import urllib.error
|
import urllib.error
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
import json
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
@@ -536,20 +537,24 @@ class GraphSettings:
|
|||||||
def set(self, type, value):
|
def set(self, type, value):
|
||||||
self.settings[type] = value
|
self.settings[type] = value
|
||||||
|
|
||||||
Locale = namedtuple('Locale', ['wxLocale', 'eosLang'])
|
|
||||||
class LocaleSettings:
|
class LocaleSettings:
|
||||||
_instance = None
|
_instance = None
|
||||||
DEFAULT = "en_US"
|
DEFAULT = "en_US"
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
'locale': DEFAULT,
|
'locale': DEFAULT,
|
||||||
'eos_locale': 'Auto' # flag for "Default" which is the same as the locale or, if not available, English
|
'eos_locale': 'Auto' # flag for "Default" which is the same as the locale or, if not available, English
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
def __init__(self):
|
||||||
def supported_langauges(cls):
|
self.settings = SettingsProvider.getInstance().getSettings('localeSettings', self.defaults)
|
||||||
"""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)}
|
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
|
@classmethod
|
||||||
def getInstance(cls):
|
def getInstance(cls):
|
||||||
@@ -557,8 +562,17 @@ class LocaleSettings:
|
|||||||
cls._instance = LocaleSettings()
|
cls._instance = LocaleSettings()
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def __init__(self):
|
def get_progress(self, lang):
|
||||||
self.settings = SettingsProvider.getInstance().getSettings('localeSettings', self.defaults)
|
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):
|
def get(self, key):
|
||||||
"""gets the raw value fo the setting"""
|
"""gets the raw value fo the setting"""
|
||||||
|
|||||||
Reference in New Issue
Block a user