X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/10f042bc5176b25dd067e57006647e769ec171da..63473fb658a8a70a67d4c68eba2deb7850739f2e:/lib/python/Screens/LanguageSelection.py diff --git a/lib/python/Screens/LanguageSelection.py b/lib/python/Screens/LanguageSelection.py old mode 100644 new mode 100755 index 7d5596fd..fce10ac5 --- a/lib/python/Screens/LanguageSelection.py +++ b/lib/python/Screens/LanguageSelection.py @@ -4,15 +4,23 @@ from Components.ActionMap import ActionMap from Components.Language import language from Components.config import config from Components.Sources.List import List +from Components.Label import Label +from Components.Pixmap import Pixmap +from Components.language_cache import LANG_TEXT -from Tools.Directories import * +def _cached(x): + return LANG_TEXT.get(config.osd.language.value, {}).get(x, "") + +from Screens.Rc import Rc + +from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN from Tools.LoadPixmap import LoadPixmap def LanguageEntryComponent(file, name, index): - png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png")) + png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "countries/" + file + ".png")) if png == None: - png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png")) + png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "countries/missing.png")) res = (index, name, png) return res @@ -52,36 +60,64 @@ class LanguageSelection(Screen): language.activateLanguage(self.oldActiveLanguage) self.close() - def run(self): + def run(self, justlocal = False): print "updating language..." lang = self["languages"].getCurrent()[0] - language.activateLanguage(lang) config.osd.language.value = lang config.osd.language.save() + self.setTitle(_cached("T2")) + + if justlocal: + return + + language.activateLanguage(lang) config.misc.languageselected.value = 0 config.misc.languageselected.save() - self.setTitle(_("Language selection")) print "ok" def updateList(self): - print "update list" - first_time = len(self.list) == 0 + first_time = not self.list - self.list = [] - if len(language.getLanguageList()) == 0: # no language available => display only english - self.list.append(LanguageEntryComponent("en", _("English"), "en_EN")) + languageList = language.getLanguageList() + if not languageList: # no language available => display only english + list = [ LanguageEntryComponent("en", _cached("en_EN"), "en_EN") ] else: - for x in language.getLanguageList(): - self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _(x[1][0]), index = x[0])) - #self.list.sort(key=lambda x: x[1][7]) + list = [ LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]) for x in languageList] + self.list = list + + #list.sort(key=lambda x: x[1][7]) print "updateList" if first_time: - self["languages"].list = self.list + self["languages"].list = list else: - self["languages"].updateList(self.list) + self["languages"].updateList(list) print "done" def changed(self): - self.run() + self.run(justlocal = True) + self.updateList() + +class LanguageWizard(LanguageSelection, Rc): + def __init__(self, session): + LanguageSelection.__init__(self, session) + Rc.__init__(self) + self.onLayoutFinish.append(self.selectKeys) + + self["wizard"] = Pixmap() + self["text"] = Label() + self.setText() + + def selectKeys(self): + self.clearSelectedKeys() + self.selectKey("UP") + self.selectKey("DOWN") + + def changed(self): + self.run(justlocal = True) self.updateList() + self.setText() + + def setText(self): + + self["text"].setText(_cached("T1"))