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