for motor 200ms to powerup before send diseqc command should be enough to
[enigma2.git] / lib / python / Components / Language.py
1 import gettext
2
3 from Tools.Directories import SCOPE_LANGUAGE, resolveFilename
4
5 class Language:
6         def __init__(self):
7                 gettext.install('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), unicode=0, codeset="utf-8")
8                 self.activeLanguage = 0
9                 self.lang = {}
10                 self.langlist = []
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(_("Icelandic"), "is", "IS")
26                 self.addLanguage(_("Italian"), "it", "IT")
27                 self.addLanguage(_("Norwegian"), "no", "NO")
28                 self.addLanguage(_("Portuguese"), "pt", "PT")
29                 self.addLanguage(_("Russian"), "ru", "RU")
30                 self.addLanguage(_("Spanish"), "es", "ES")
31                 self.addLanguage(_("Swedish"), "sv", "SE")
32                 self.addLanguage(_("Turkish"), "tr", "TR")
33
34                 self.callbacks = []
35
36         def addLanguage(self, name, lang, country):
37                 try:
38                         self.lang[str(lang + "_" + country)] = ((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
39                         self.langlist.append(str(lang + "_" + country))
40                 except:
41                         print "Language " + str(name) + " not found"
42
43         def activateLanguage(self, index):
44                 try:
45                         print "Activating language " + str(self.lang[index][0])
46                         self.lang[index][1].install()
47                         self.activeLanguage = index
48                         for x in self.callbacks:
49                                 x()
50                 except:
51                         print "Selected language does not exist!"
52
53         def getLanguageList(self):
54                 list = []
55                 for x in self.langlist:
56                         list.append((x, self.lang[x]))
57                 return list
58
59         def getActiveLanguage(self):
60                 return self.activeLanguage
61
62         def getLanguage(self):
63                 try:
64                         return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3])
65                 except:
66                         return ''
67
68         def addCallback(self, callback):
69                 self.callbacks.append(callback)
70
71 language = Language()