1 from Screen import Screen
3 from Components.ActionMap import ActionMap
4 from Components.Language import language
5 from Components.config import config
6 from Components.Sources.List import List
7 from Components.Label import Label
8 from Components.Pixmap import Pixmap
9 from Components.language_cache import LANG_TEXT
12 return LANG_TEXT.get(config.osd.language.value, {}).get(x, "")
14 from Screens.Rc import Rc
16 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
18 from Tools.LoadPixmap import LoadPixmap
20 def LanguageEntryComponent(file, name, index):
21 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
23 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
24 res = (index, name, png)
27 class LanguageSelection(Screen):
28 def __init__(self, session):
29 Screen.__init__(self, session)
31 self.oldActiveLanguage = language.getActiveLanguage()
34 self["languages"] = List(self.list)
35 self["languages"].onSelectionChanged.append(self.changed)
38 self.onLayoutFinish.append(self.selectActiveLanguage)
40 self["actions"] = ActionMap(["OkCancelActions"],
43 "cancel": self.cancel,
46 def selectActiveLanguage(self):
47 activeLanguage = language.getActiveLanguage()
50 if x[0] == activeLanguage:
51 self["languages"].index = pos
60 language.activateLanguage(self.oldActiveLanguage)
63 def run(self, justlocal = False):
64 print "updating language..."
65 lang = self["languages"].getCurrent()[0]
66 config.osd.language.value = lang
67 config.osd.language.save()
68 self.setTitle(_cached("T2"))
73 language.activateLanguage(lang)
74 config.misc.languageselected.value = 0
75 config.misc.languageselected.save()
79 first_time = len(self.list) == 0
82 if len(language.getLanguageList()) == 0: # no language available => display only english
83 self.list.append(LanguageEntryComponent("en", _cached("en_EN"), "en_EN"))
85 for x in language.getLanguageList():
86 self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]))
87 #self.list.sort(key=lambda x: x[1][7])
91 self["languages"].list = self.list
93 self["languages"].updateList(self.list)
97 self.run(justlocal = True)
100 class LanguageWizard(LanguageSelection, Rc):
101 def __init__(self, session):
102 LanguageSelection.__init__(self, session)
104 self.onLayoutFinish.append(self.selectKeys)
106 self["wizard"] = Pixmap()
107 self["text"] = Label()
110 def selectKeys(self):
111 self.clearSelectedKeys()
113 self.selectKey("DOWN")
116 self.run(justlocal = True)
122 self["text"].setText(_cached("T1"))