456fe0264694c3904e6ebda188635cefca68796f
[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                 self.addLanguage(_("English"), "en")
13                 self.addLanguage(_("German"), "de")
14                 self.addLanguage(_("Arabic"), "ar")
15
16         def addLanguage(self, name, lang):
17                 try:
18                         self.lang.append((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang))
19                 except:
20                         print "Language " + str(name) + " not found"
21
22         def activateLanguage(self, index):
23                 try:
24                         print "Activating language " + str(self.lang[index][0])
25                         self.lang[index][1].install()
26                         self.activeLanguage = index
27                 except:
28                         print "Selected language does not exist!"
29                 
30         def getLanguageList(self):
31                 list = []
32                 for x in self.lang:
33                         list.append(x[0])
34                 return list
35
36 language = Language()