3 from Tools.Directories import SCOPE_LANGUAGE, resolveFilename
7 gettext.install('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), unicode=0, codeset="utf-8")
8 self.activeLanguage = 0
11 # FIXME make list dynamically
12 # name, iso-639 language, iso-3166 country. Please don't mix language&country!
13 self.addLanguage(_("English"), "en", "EN")
14 self.addLanguage(_("German"), "de", "DE")
15 self.addLanguage(_("Arabic"), "ar", "AE")
16 self.addLanguage(_("Catalan"), "ca", "AD")
17 self.addLanguage(_("Croatian"), "hr", "HR")
18 self.addLanguage(_("Czech"), "cs", "CZ")
19 self.addLanguage(_("Danish"), "da", "DK")
20 self.addLanguage(_("Dutch"), "nl", "NL")
21 self.addLanguage(_("Finnish"), "fi", "FI")
22 self.addLanguage(_("French"), "fr", "FR")
23 self.addLanguage(_("Greek"), "el", "GR")
24 self.addLanguage(_("Hungarian"), "hu", "HU")
25 self.addLanguage(_("Lithuanian"), "lt", "LT")
26 self.addLanguage(_("Icelandic"), "is", "IS")
27 self.addLanguage(_("Italian"), "it", "IT")
28 self.addLanguage(_("Norwegian"), "no", "NO")
29 self.addLanguage(_("Polish"), "pl", "PL")
30 self.addLanguage(_("Portuguese"), "pt", "PT")
31 self.addLanguage(_("Russian"), "ru", "RU")
32 self.addLanguage(_("Spanish"), "es", "ES")
33 self.addLanguage(_("Swedish"), "sv", "SE")
34 self.addLanguage(_("Turkish"), "tr", "TR")
38 def addLanguage(self, name, lang, country):
40 self.lang[str(lang + "_" + country)] = ((_(name), lang, country))
41 self.langlist.append(str(lang + "_" + country))
43 print "Language " + str(name) + " not found"
45 def activateLanguage(self, index):
47 lang = self.lang[index]
48 print "Activating language " + lang[0]
49 gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang[1]]).install()
50 self.activeLanguage = index
51 for x in self.callbacks:
54 print "Selected language does not exist!"
56 def activateLanguageIndex(self, index):
57 if index < len(self.langlist):
58 self.activateLanguage(self.langlist[index])
60 def getLanguageList(self):
62 for x in self.langlist:
63 list.append((x, self.lang[x]))
66 def getActiveLanguage(self):
67 return self.activeLanguage
69 def getActiveLanguageIndex(self):
70 for count in range(len(self.langlist)):
71 if self.langlist[count] == self.activeLanguage:
75 def getLanguage(self):
77 return str(self.lang[self.activeLanguage][1]) + "_" + str(self.lang[self.activeLanguage][2])
81 def addCallback(self, callback):
82 self.callbacks.append(callback)