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_CURRENT_SKIN
18 from Tools.LoadPixmap import LoadPixmap
20 def LanguageEntryComponent(file, name, index):
21 png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "countries/" + file + ".png"))
23 png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "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 = not self.list
81 languageList = language.getLanguageList()
82 if not languageList: # no language available => display only english
83 list = [ LanguageEntryComponent("en", _cached("en_EN"), "en_EN") ]
85 list = [ LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]) for x in languageList]
88 #list.sort(key=lambda x: x[1][7])
92 self["languages"].list = list
94 self["languages"].updateList(list)
98 self.run(justlocal = True)
101 class LanguageWizard(LanguageSelection, Rc):
102 def __init__(self, session):
103 LanguageSelection.__init__(self, session)
105 self.onLayoutFinish.append(self.selectKeys)
107 self["wizard"] = Pixmap()
108 self["text"] = Label()
111 def selectKeys(self):
112 self.clearSelectedKeys()
114 self.selectKey("DOWN")
117 self.run(justlocal = True)
123 self["text"].setText(_cached("T1"))