use callbacks to signal the change of language
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 21 Mar 2006 09:26:44 +0000 (09:26 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Tue, 21 Mar 2006 09:26:44 +0000 (09:26 +0000)
functions can get the language code with:

from Components.Language import language
lang = language.getLanguage()

lang reads for example "de_DE" or "en_EN"

lib/python/Components/Language.py

index 0769771..08bcfec 100644 (file)
@@ -15,6 +15,8 @@ class Language:
                self.addLanguage(_("Arabic"), "ar", "AE")
                self.addLanguage(_("Dutch"), "nl", "NL")
                self.addLanguage(_("Spanish"), "es", "ES")
+               
+               self.callbacks = []
 
        def addLanguage(self, name, lang, country):
                try:
@@ -27,6 +29,8 @@ class Language:
                        print "Activating language " + str(self.lang[index][0])
                        self.lang[index][1].install()
                        self.activeLanguage = index
+                       for x in callback:
+                               callback()
                except:
                        print "Selected language does not exist!"
                
@@ -35,5 +39,11 @@ class Language:
                for x in self.lang:
                        list.append(x[0])
                return list
-
+       
+       def getLanguage(self):
+               return str(self.lang[self.activeLanguage][3]) + "_" + str(self.lang[self.activeLanguage][4])
+       
+       def addCallback(self, callback):
+               self.callbacks.append(callback)
+               
 language = Language()