update de translation
[enigma2-plugins.git] / mytube / src / __init__.py
1 # -*- coding: ISO-8859-1 -*-
2 from Components.Language import language
3 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
4 import os,gettext
5 PluginLanguageDomain = "MyTube"
6 PluginLanguagePath = "Extensions/MyTube/po"
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 "[MyTube] 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 "[MyTube] fallback to default translation for", txt
18                 t = gettext.gettext(txt)
19         return t
20
21 localeInit()
22 language.addCallback(localeInit)