[AutoResolution]Add German translation
[enigma2-plugins.git] / autoresolution / src / __init__.py
1 # -*- coding: utf-8 -*-
2
3 from Components.Language import language
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
5 import os,gettext
6  
7 PluginLanguageDomain = "AutoResolution"
8 PluginLanguagePath = "SystemPlugins/AutoResolution/locale"
9  
10 def localeInit():
11         lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
12         os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
13         #print "[%s] set language to " %(PluginLanguageDomain), lang
14         gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
15
16 def _(txt):
17         t = gettext.dgettext(PluginLanguageDomain, txt)
18         if t == txt:
19                 #print "[%s] fallback to default translation for %s" %(PluginLanguageDomain, txt)
20                 t = gettext.gettext(txt)
21         return t
22
23 localeInit()
24 language.addCallback(localeInit)