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