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
10 from Screens.Rc import Rc
12 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
14 from Tools.LoadPixmap import LoadPixmap
16 def LanguageEntryComponent(file, name, index):
17 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
19 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
20 res = (index, name, png)
23 class LanguageSelection(Screen):
24 def __init__(self, session):
25 Screen.__init__(self, session)
27 self.oldActiveLanguage = language.getActiveLanguage()
30 self["languages"] = List(self.list)
31 self["languages"].onSelectionChanged.append(self.changed)
34 self.onLayoutFinish.append(self.selectActiveLanguage)
36 self["actions"] = ActionMap(["OkCancelActions"],
39 "cancel": self.cancel,
42 def selectActiveLanguage(self):
43 activeLanguage = language.getActiveLanguage()
46 if x[0] == activeLanguage:
47 self["languages"].index = pos
56 language.activateLanguage(self.oldActiveLanguage)
60 print "updating language..."
61 lang = self["languages"].getCurrent()[0]
62 language.activateLanguage(lang)
63 config.osd.language.value = lang
64 config.osd.language.save()
65 config.misc.languageselected.value = 0
66 config.misc.languageselected.save()
67 self.setTitle(_("Language selection"))
72 first_time = len(self.list) == 0
75 if len(language.getLanguageList()) == 0: # no language available => display only english
76 self.list.append(LanguageEntryComponent("en", _("English"), "en_EN"))
78 for x in language.getLanguageList():
79 self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _(x[1][0]), index = x[0]))
80 #self.list.sort(key=lambda x: x[1][7])
84 self["languages"].list = self.list
86 self["languages"].updateList(self.list)
93 class LanguageWizard(LanguageSelection, Rc):
94 def __init__(self, session):
95 LanguageSelection.__init__(self, session)
97 self.onLayoutFinish.append(self.selectKeys)
99 self["wizard"] = Pixmap()
100 self["text"] = Label()
103 def selectKeys(self):
104 self.clearSelectedKeys()
106 self.selectKey("DOWN")
114 self["text"].setText(_("Please use the UP and DOWN keys to select your language. Afterwards press the OK button."))