Move supported languages to the LocaleSettings class, and use the command parameter as an override

This commit is contained in:
blitzmann
2020-06-19 22:44:09 -04:00
parent d939b0e565
commit d9e5349edd
3 changed files with 12 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ import config
import os
from logbook import Logger
pyfalog = Logger(__name__)
from service.settings import LocaleSettings
class PyfaApp(wx.App):
def OnInit(self):
@@ -37,7 +38,7 @@ class PyfaApp(wx.App):
#-----------------------------------------------------------------------
def UpdateLanguage(self, lang = "en_US"):
def UpdateLanguage(self, lang_override = None):
"""
Update the language to the requested one.
@@ -52,13 +53,10 @@ class PyfaApp(wx.App):
# Language domain.
langDomain = "lang"
lang = lang_override or LocaleSettings.getInstance().get('locale')
# Languages you want to support.
supLang = {
"en_US": wx.LANGUAGE_ENGLISH,
"zh_CN": wx.LANGUAGE_CHINESE_SIMPLIFIED,
"de": wx.LANGUAGE_GERMAN
}
supLang = LocaleSettings.supported_langauges
# If an unsupported language is requested default to English.
if lang in supLang:

View File

@@ -74,7 +74,7 @@ parser.add_option("-s", "--savepath", action="store", dest="savepath", help="Set
parser.add_option("-l", "--logginglevel", action="store", dest="logginglevel", help="Set desired logging level [Critical|Error|Warning|Info|Debug]", default="Error")
parser.add_option("-p", "--profile", action="store", dest="profile_path", help="Set location to save profileing.", default=None)
parser.add_option("-i", "--language", action="store", dest="language", help="Set the language for pyfa", default="en_US")
parser.add_option("-i", "--language", action="store", dest="language", help="Set the language for pyfa", default=None)
(options, args) = parser.parse_args()

View File

@@ -539,6 +539,12 @@ class GraphSettings:
class LocaleSettings:
_instance = None
supported_langauges = {
"en_US": wx.LANGUAGE_ENGLISH,
"zh_CN": wx.LANGUAGE_CHINESE_SIMPLIFIED,
# todo: add the others that EVE supports
}
@classmethod
def getInstance(cls):
if cls._instance is None:
@@ -548,7 +554,7 @@ class LocaleSettings:
def __init__(self):
defaults = {
'locale': wx.LANGUAGE_DEFAULT
'locale': "en_US"
}
self.settings = SettingsProvider.getInstance().getSettings('localeSettings', defaults)