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 Tools.LoadPixmap import LoadPixmap
12 def LanguageEntryComponent(file, name, index):
13 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
15 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png"))
16 res = (index, name, png)
19 class LanguageSelection(Screen):
20 def __init__(self, session):
21 Screen.__init__(self, session)
23 self.oldActiveLanguage = language.getActiveLanguage()
26 self["languages"] = List(self.list)
27 self["languages"].onSelectionChanged.append(self.changed)
30 self.onLayoutFinish.append(self.selectActiveLanguage)
32 self["actions"] = ActionMap(["OkCancelActions"],
35 "cancel": self.cancel,
38 def selectActiveLanguage(self):
39 activeLanguage = language.getActiveLanguage()
42 if x[0] == activeLanguage:
43 self["languages"].index = pos
52 language.activateLanguage(self.oldActiveLanguage)
56 print "updating language..."
57 lang = self["languages"].getCurrent()[0]
58 language.activateLanguage(lang)
59 config.osd.language.value = lang
60 config.osd.language.save()
61 config.misc.languageselected.value = 0
62 config.misc.languageselected.save()
63 self.setTitle(_("Language selection"))
68 first_time = len(self.list) == 0
71 if len(language.getLanguageList()) == 0: # no language available => display only english
72 self.list.append(LanguageEntryComponent("en", _("English"), "en_EN"))
74 for x in language.getLanguageList():
75 self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _(x[1][0]), index = x[0]))
76 #self.list.sort(key=lambda x: x[1][7])
80 self["languages"].list = self.list
82 self["languages"].updateList(self.list)