From 937adb68d7ed525c19dc2de7f0c4c815705c560a Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 24 Jul 2020 22:14:54 -0400 Subject: [PATCH] Show user-friendly name for the eos lang dropdown as well --- .../pyfaGeneralPreferences.py | 14 ++++++++++---- locale_test/getTextLocale.py | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 locale_test/getTextLocale.py diff --git a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py index f7cadb495a..98eae19a75 100644 --- a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py @@ -119,11 +119,15 @@ def populatePanel(self, panel): self.stEosLangLabel.Wrap(-1) eosLangSizer.Add(self.stEosLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) - self.eosLangChoices = eos.config.translation_mapping.keys() - self.chEosLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [LocaleSettings.defaults['eos_locale']]+sorted([x for x in self.eosLangChoices]), 0) + self.eosLangChoices = [(LocaleSettings.defaults['eos_locale'], LocaleSettings.defaults['eos_locale'])] + \ + sorted([(wx.Locale.FindLanguageInfo(x).Description, x) for x in eos.config.translation_mapping.keys()], key=lambda x: x[0]) + + self.chEosLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [x[0] for x in self.eosLangChoices], 0) self.chEosLang.Bind(wx.EVT_CHOICE, self.onEosLangSelection) - self.chEosLang.SetStringSelection(self.localeSettings.get('eos_locale')) + selectedIndex = self.eosLangChoices.index( + next((x for x in self.eosLangChoices if x[1] == self.localeSettings.get('eos_locale')), None)) + self.chEosLang.SetSelection(selectedIndex) eosLangSizer.Add(self.chEosLang, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) @@ -174,7 +178,9 @@ def onLangSelection(self, event): self.localeSettings.set('locale', locale.CanonicalName) def onEosLangSelection(self, event): - self.localeSettings.set('eos_locale', self.chEosLang.GetString(self.chEosLang.GetSelection())) + selection = self.chEosLang.GetSelection() + locale = self.eosLangChoices[selection] + self.localeSettings.set('eos_locale', locale[1]) def onCBGlobalColorBySlot(self, event): # todo: maybe create a SettingChanged event that we can fire, and have other things hook into, instead of having the preference panel itself handle the diff --git a/locale_test/getTextLocale.py b/locale_test/getTextLocale.py new file mode 100644 index 0000000000..d0cd5cbac1 --- /dev/null +++ b/locale_test/getTextLocale.py @@ -0,0 +1,4 @@ +import gettext +gettext.install('lang', './locale') +gettext.translation('lang', './locale', languages=['zh_CH']).install(True) +print(_("Sample Title Text English")) \ No newline at end of file