From bb59fd202b257cce05684912216678d9872ff0cc Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 17 Nov 2005 21:27:22 +0000 Subject: some basic language support (already working a bit) --- lib/python/Components/Language.py | 28 ++++++++++++++++++++++++++++ lib/python/Components/Makefile.am | 2 +- lib/python/Components/SetupDevices.py | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 lib/python/Components/Language.py (limited to 'lib/python/Components') diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py new file mode 100644 index 00000000..8d966b68 --- /dev/null +++ b/lib/python/Components/Language.py @@ -0,0 +1,28 @@ +import gettext +import os + +class Language: + def __init__(self): + gettext.install('enigma2', '/enigma2/po') + self.lang = [] + # FIXME make list dynamically + self.addLanguage(_("English"), "en") + self.addLanguage(_("German"), "de") + + def addLanguage(self, name, lang): + try: + self.lang.append((_(name), gettext.translation('enigma2', '/enigma2/po', languages=[lang]))) + except: + print "Language " + str(name) + " not found" + + def activateLanguage(self, index): + print "Activating language " + str(self.lang[index][0]) + self.lang[index][1].install() + + def getLanguageList(self): + list = [] + for x in self.lang: + list.append(x[0]) + return list + +language = Language() \ No newline at end of file diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index 0e1894aa..f49c7545 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -9,4 +9,4 @@ install_PYTHON = \ GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py \ InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py \ AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py \ - EpgList.py ScrollLabel.py Timezones.py + EpgList.py ScrollLabel.py Timezones.py Language.py diff --git a/lib/python/Components/SetupDevices.py b/lib/python/Components/SetupDevices.py index 612bb8c8..6ce8737b 100644 --- a/lib/python/Components/SetupDevices.py +++ b/lib/python/Components/SetupDevices.py @@ -6,6 +6,7 @@ from config import ConfigSlider from config import configSelection from config import configText from Components.Timezones import timezones +from Components.Language import language def InitSetupDevices(): @@ -26,7 +27,12 @@ def InitSetupDevices(): config.osd.alpha = configElement("config.osd.alpha", ConfigSlider, 0, ""); config.osd.bright = configElement("config.osd.bright", ConfigSlider, 5, ""); config.osd.contrast = configElement("config.osd.contrast", ConfigSlider, 5, ""); - config.osd.language = configElement("config.osd.language", configSelection, 0, ("English", "English US") ); + + def languageNotifier(configElement): + language.activateLanguage(configElement.value) + + config.osd.language = configElement("config.osd.language", configSelection, 0, language.getLanguageList() ); + config.osd.language.addNotifier(languageNotifier) config.parental = ConfigSubsection(); config.parental.lock = configElement("config.parental.lock", configSelection, 1, ("Enable", "Disable") ); -- cgit v1.2.3