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