update french language
[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                 self.langlist = []
12                 # FIXME make list dynamically
13                 # name, iso-639 language, iso-3166 country. Please don't mix language&country!
14                 self.addLanguage(_("English"), "en", "EN")
15                 self.addLanguage(_("German"), "de", "DE")
16                 self.addLanguage(_("Arabic"), "ar", "AE")
17                 self.addLanguage(_("Danish"), "da", "DK")
18                 self.addLanguage(_("Dutch"), "nl", "NL")
19                 self.addLanguage(_("Finnish"), "fi", "FI")
20                 self.addLanguage(_("French"), "fr", "FR")
21                 self.addLanguage(_("Icelandic"), "is", "IS")
22                 self.addLanguage(_("Italian"), "it", "IT")
23                 self.addLanguage(_("Norwegian"), "no", "NO")
24                 self.addLanguage(_("Spanish"), "es", "ES")
25                 self.addLanguage(_("Swedish"), "sv", "SE")
26                 
27                 self.callbacks = []
28
29         def addLanguage(self, name, lang, country):
30                 try:
31                         self.lang[str(lang + "_" + country)] = ((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
32                         self.langlist.append(str(lang + "_" + country))
33                 except:
34                         print "Language " + str(name) + " not found"
35
36         def activateLanguage(self, index):
37                 try:
38                         print "Activating language " + str(self.lang[index][0])
39                         self.lang[index][1].install()
40                         self.activeLanguage = index
41                         for x in self.callbacks:
42                                 x()
43                 except:
44                         print "Selected language does not exist!"
45
46         def getLanguageList(self):
47                 list = []
48                 for x in self.langlist:
49                         list.append((x, self.lang[x]))
50                 return list
51         
52         def getActiveLanguage(self):
53                 return self.activeLanguage
54         
55         def getLanguage(self):
56                 return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3])
57         
58         def addCallback(self, callback):
59                 self.callbacks.append(callback)
60                 
61 language = Language()