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
8 from Tools.Directories import *
10 from enigma import eListboxPythonMultiContent, loadPNG, gFont, RT_HALIGN_LEFT
12 def LanguageEntryComponent(file, name, index):
14 res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 10, 200, 50, 0, RT_HALIGN_LEFT ,name))
15 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
17 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
18 res.append((eListboxPythonMultiContent.TYPE_PIXMAP, 10, 5, 60, 40, png))
22 class LanguageSelection(Screen):
23 def __init__(self, session):
24 Screen.__init__(self, session)
26 self.oldActiveLanguage = language.getActiveLanguage()
29 self["languages"] = List(self.list, item_height=50, fonts = [gFont("Regular", 20)])
30 self["languages"].onSelectionChanged.append(self.changed)
33 self.onLayoutFinish.append(self.selectActiveLanguage)
35 self["actions"] = ActionMap(["OkCancelActions"],
38 "cancel": self.cancel,
41 def selectActiveLanguage(self):
42 activeLanguage = language.getActiveLanguage()
45 if x[0] == activeLanguage:
46 self["languages"].index = pos
55 language.activateLanguage(self.oldActiveLanguage)
59 print "updating language..."
60 lang = self["languages"].getCurrent()[0]
61 language.activateLanguage(lang)
62 config.osd.language.value = lang
63 config.osd.language.save()
64 config.misc.languageselected.value = 0
65 config.misc.languageselected.save()
66 self.setTitle(_("Language selection"))
71 first_time = len(self.list) == 0
74 if len(language.getLanguageList()) == 0: # no language available => display only english
75 self.list.append(LanguageEntryComponent("en", _("English"), "en_EN"))
77 for x in language.getLanguageList():
78 self.list.append(LanguageEntryComponent(file = x[1][3].lower(), name = _(x[1][0]), index = x[0]))
79 #self.list.sort(key=lambda x: x[1][7])
83 self["languages"].list = self.list
85 self["languages"].updateList(self.list)