Starting to generate list of languages dynamically
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import wx
|
import wx
|
||||||
import config
|
import config
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from logbook import Logger
|
from logbook import Logger
|
||||||
pyfalog = Logger(__name__)
|
pyfalog = Logger(__name__)
|
||||||
from service.settings import LocaleSettings
|
from service.settings import LocaleSettings
|
||||||
@@ -63,7 +64,6 @@ class PyfaApp(wx.App):
|
|||||||
selLang = supLang[lang].wxLocale
|
selLang = supLang[lang].wxLocale
|
||||||
else:
|
else:
|
||||||
selLang = wx.LANGUAGE_ENGLISH_US
|
selLang = wx.LANGUAGE_ENGLISH_US
|
||||||
|
|
||||||
if self.locale:
|
if self.locale:
|
||||||
assert sys.getrefcount(self.locale) <= 2
|
assert sys.getrefcount(self.locale) <= 2
|
||||||
del self.locale
|
del self.locale
|
||||||
@@ -72,7 +72,7 @@ class PyfaApp(wx.App):
|
|||||||
pyfalog.debug("Setting language to: " + lang)
|
pyfalog.debug("Setting language to: " + lang)
|
||||||
self.locale = wx.Locale(selLang)
|
self.locale = wx.Locale(selLang)
|
||||||
if self.locale.IsOk():
|
if self.locale.IsOk():
|
||||||
success = self.locale.AddCatalog(langDomain, selLang)
|
success = self.locale.AddCatalog(langDomain)
|
||||||
if not success:
|
if not success:
|
||||||
print("Langauage catalog not successfully loaded")
|
print("Langauage catalog not successfully loaded")
|
||||||
|
|
||||||
|
|||||||
@@ -102,8 +102,9 @@ 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 = self.localeSettings.supported_langauges.keys()
|
self.langChoices = sorted([wx.Locale.FindLanguageInfo(x) for x in wx.Translations.Get().GetAvailableTranslations('lang')], key=lambda x: x.Description)
|
||||||
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, sorted([x for x in self.langChoices]), 0)
|
|
||||||
|
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [x.Description for x in self.langChoices], 0)
|
||||||
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)
|
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)
|
||||||
|
|
||||||
self.chLang.SetStringSelection(self.localeSettings.get('locale'))
|
self.chLang.SetStringSelection(self.localeSettings.get('locale'))
|
||||||
@@ -167,7 +168,9 @@ class PFGeneralPref(PreferenceView):
|
|||||||
panel.Layout()
|
panel.Layout()
|
||||||
|
|
||||||
def onLangSelection(self, event):
|
def onLangSelection(self, event):
|
||||||
self.localeSettings.set('locale', self.chLang.GetString(self.chLang.GetSelection()))
|
selection = self.chLang.GetSelection()
|
||||||
|
locale = self.langChoices[selection]
|
||||||
|
self.localeSettings.set('locale', locale.CanonicalName)
|
||||||
|
|
||||||
def onEosLangSelection(self, event):
|
def onEosLangSelection(self, event):
|
||||||
self.localeSettings.set('eos_locale', self.chEosLang.GetString(self.chEosLang.GetSelection()))
|
self.localeSettings.set('eos_locale', self.chEosLang.GetString(self.chEosLang.GetSelection()))
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ class LocaleSettings:
|
|||||||
def get_eos_locale(self):
|
def get_eos_locale(self):
|
||||||
"""gets the effective value of the setting"""
|
"""gets the effective value of the setting"""
|
||||||
val = self.settings['eos_locale']
|
val = self.settings['eos_locale']
|
||||||
|
return 'en'
|
||||||
return val if val != self.defaults['eos_locale'] else self.supported_langauges.get(self.settings['locale'], 'en').eosLang
|
return val if val != self.defaults['eos_locale'] else self.supported_langauges.get(self.settings['locale'], 'en').eosLang
|
||||||
|
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
|
|||||||
Reference in New Issue
Block a user