- add positioner plugin (just basic gui atm)
[enigma2.git] / lib / python / Components / Language.py
1 import gettext
2 import os
3
4 from Tools.Directories import *
5
6 class Language:
7         def __init__(self):
8                 gettext.install('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), unicode=0, codeset="utf-8")
9                 self.activeLanguage = 0
10                 self.lang = []
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(_("Dutch"), "nl", "NL")
17                 self.addLanguage(_("Spanish"), "es", "ES")
18
19         def addLanguage(self, name, lang, country):
20                 try:
21                         self.lang.append((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
22                 except:
23                         print "Language " + str(name) + " not found"
24
25         def activateLanguage(self, index):
26                 try:
27                         print "Activating language " + str(self.lang[index][0])
28                         self.lang[index][1].install()
29                         self.activeLanguage = index
30                 except:
31                         print "Selected language does not exist!"
32                 
33         def getLanguageList(self):
34                 list = []
35                 for x in self.lang:
36                         list.append(x[0])
37                 return list
38
39 language = Language()