Skip to content

Commit

Permalink
Starting to generate list of languages dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed Jul 25, 2020
1 parent cb99151 commit ac1e6fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gui/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import wx
import config
import os

from logbook import Logger
pyfalog = Logger(__name__)
from service.settings import LocaleSettings
Expand Down Expand Up @@ -63,7 +64,6 @@ def UpdateLanguage(self, lang=None):
selLang = supLang[lang].wxLocale
else:
selLang = wx.LANGUAGE_ENGLISH_US

if self.locale:
assert sys.getrefcount(self.locale) <= 2
del self.locale
Expand All @@ -72,7 +72,7 @@ def UpdateLanguage(self, lang=None):
pyfalog.debug("Setting language to: " + lang)
self.locale = wx.Locale(selLang)
if self.locale.IsOk():
success = self.locale.AddCatalog(langDomain, selLang)
success = self.locale.AddCatalog(langDomain)
if not success:
print("Langauage catalog not successfully loaded")

Expand Down
9 changes: 6 additions & 3 deletions gui/builtinPreferenceViews/pyfaGeneralPreferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ def populatePanel(self, panel):
self.stLangLabel.Wrap(-1)
langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

self.langChoices = self.localeSettings.supported_langauges.keys()
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, sorted([x for x in self.langChoices]), 0)
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, [x.Description for x in self.langChoices], 0)
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)

self.chLang.SetStringSelection(self.localeSettings.get('locale'))
Expand Down Expand Up @@ -167,7 +168,9 @@ def populatePanel(self, panel):
panel.Layout()

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):
self.localeSettings.set('eos_locale', self.chEosLang.GetString(self.chEosLang.GetSelection()))
Expand Down
1 change: 1 addition & 0 deletions service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ def get(self, key):
def get_eos_locale(self):
"""gets the effective value of the setting"""
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

def set(self, key, value):
Expand Down

0 comments on commit ac1e6fe

Please sign in to comment.