diff --git a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py index a6d21ded0..a3394d9df 100644 --- a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py @@ -35,6 +35,58 @@ class PFGeneralPref(PreferenceView): self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) + langBox = wx.StaticBoxSizer(wx.VERTICAL, panel, _t("Language (requires restart)")) + mainSizer.Add(langBox, 0, wx.EXPAND | wx.TOP | wx.RIGHT | wx.BOTTOM, 10) + + langSizer = wx.BoxSizer(wx.HORIZONTAL) + + self.stLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("pyfa:"), wx.DefaultPosition, wx.DefaultSize, 0) + self.stLangLabel.Wrap(-1) + langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) + + self.langChoices = sorted([langInfo for lang, langInfo in LocaleSettings.supported_langauges().items()], key=lambda x: x.Description) + + 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) + + selectedIndex = self.langChoices.index(next((x for x in self.langChoices if x.CanonicalName == self.localeSettings.get('locale')), None)) + self.chLang.SetSelection(selectedIndex) + + langSizer.Add(self.chLang, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) + langBox.Add(langSizer) + langBox.Add(hl.HyperLinkCtrl(panel, -1, + _t("Interested in helping with translations?"), + URL="https://github.com/pyfa-org/Pyfa/blob/master/locale/README.md" + ), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 15) + eosLangSizer = wx.BoxSizer(wx.HORIZONTAL) + + self.stEosLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("EVE Data:"), wx.DefaultPosition, wx.DefaultSize, 0) + self.stEosLangLabel.Wrap(-1) + eosLangSizer.Add(self.stEosLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) + + 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) + + 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) + + langBox.Add(eosLangSizer) + langBox.Add(wx.StaticText(panel, wx.ID_ANY, + _t("Auto will use the same language pyfa uses if available, otherwise English"), + wx.DefaultPosition, + wx.DefaultSize, 0), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 15) + self.cbGlobalChar = wx.CheckBox(panel, wx.ID_ANY, _t("Use global character"), wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5) @@ -94,57 +146,6 @@ class PFGeneralPref(PreferenceView): mainSizer.Add(self.rbAddLabels, 0, wx.EXPAND | wx.TOP | wx.RIGHT | wx.BOTTOM, 10) self.rbAddLabels.Bind(wx.EVT_RADIOBOX, self.OnAddLabelsChange) - langBox = wx.StaticBoxSizer(wx.VERTICAL, panel, _t("Language (requires restart)")) - mainSizer.Add(langBox, 0, wx.EXPAND | wx.TOP | wx.RIGHT | wx.BOTTOM, 10) - - langSizer = wx.BoxSizer(wx.HORIZONTAL) - - self.stLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("pyfa:"), wx.DefaultPosition, wx.DefaultSize, 0) - self.stLangLabel.Wrap(-1) - langSizer.Add(self.stLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) - - self.langChoices = sorted([langInfo for lang, langInfo in LocaleSettings.supported_langauges().items()], key=lambda x: x.Description) - - 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) - - selectedIndex = self.langChoices.index(next((x for x in self.langChoices if x.CanonicalName == self.localeSettings.get('locale')), None)) - self.chLang.SetSelection(selectedIndex) - - langSizer.Add(self.chLang, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) - langBox.Add(langSizer) - langBox.Add(hl.HyperLinkCtrl(panel, -1, - _t("Interested in helping with translations?"), - URL="https://github.com/pyfa-org/Pyfa/blob/master/locale/README.md" - ), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 15) - eosLangSizer = wx.BoxSizer(wx.HORIZONTAL) - - self.stEosLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("EVE Data:"), wx.DefaultPosition, wx.DefaultSize, 0) - self.stEosLangLabel.Wrap(-1) - eosLangSizer.Add(self.stEosLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5) - - 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) - - 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) - - langBox.Add(eosLangSizer) - langBox.Add(wx.StaticText(panel, wx.ID_ANY, - _t("Auto will use the same language pyfa uses if available, otherwise English"), - wx.DefaultPosition, - wx.DefaultSize, 0), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 15) self.sFit = Fit.getInstance() self.cbGlobalChar.SetValue(self.sFit.serviceFittingOptions["useGlobalCharacter"])