Starting to generate list of languages dynamically

This commit is contained in:
Ryan Holmes
2020-07-24 20:42:47 -04:00
parent cb99151f69
commit ac1e6fe5b7
3 changed files with 9 additions and 5 deletions

View File

@@ -102,8 +102,9 @@ class PFGeneralPref(PreferenceView):
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'))
@@ -167,7 +168,9 @@ class PFGeneralPref(PreferenceView):
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()))