speedup opening of long movielists
[enigma2.git] / lib / python / Components / Language.py
index 08bcfec4b73ccc29184f4425b9caa66fa33480a7..bf211cf62d44d6ec36eaca6bdbdfb06fbaf02219 100644 (file)
@@ -7,7 +7,7 @@ class Language:
        def __init__(self):
                gettext.install('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), unicode=0, codeset="utf-8")
                self.activeLanguage = 0
-               self.lang = []
+               self.lang = {}
                # FIXME make list dynamically
                # name, iso-639 language, iso-3166 country. Please don't mix language&country!
                self.addLanguage(_("English"), "en", "EN")
@@ -15,12 +15,13 @@ class Language:
                self.addLanguage(_("Arabic"), "ar", "AE")
                self.addLanguage(_("Dutch"), "nl", "NL")
                self.addLanguage(_("Spanish"), "es", "ES")
+               self.addLanguage(_("Icelandic"), "is", "IS")
                
                self.callbacks = []
 
        def addLanguage(self, name, lang, country):
                try:
-                       self.lang.append((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
+                       self.lang[str(lang + "_" + country)] = ((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
                except:
                        print "Language " + str(name) + " not found"
 
@@ -29,19 +30,22 @@ class Language:
                        print "Activating language " + str(self.lang[index][0])
                        self.lang[index][1].install()
                        self.activeLanguage = index
-                       for x in callback:
-                               callback()
+                       for x in self.callbacks:
+                               x()
                except:
                        print "Selected language does not exist!"
-               
+
        def getLanguageList(self):
                list = []
-               for x in self.lang:
-                       list.append(x[0])
+               for x in self.lang.keys():
+                       list.append((x, self.lang[x]))
                return list
        
+       def getActiveLanguage(self):
+               return self.activeLanguage
+       
        def getLanguage(self):
-               return str(self.lang[self.activeLanguage][3]) + "_" + str(self.lang[self.activeLanguage][4])
+               return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3])
        
        def addCallback(self, callback):
                self.callbacks.append(callback)