VPS-Plugin: initial checkin
[enigma2-plugins.git] / vps / src_py / __init__.py
1 # -*- coding: utf-8 -*-
2 from Components.Language import language
3 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
4 from os import environ as os_environ
5 import gettext
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         gettext.bindtextdomain("vps", resolveFilename(SCOPE_PLUGINS, "SystemPlugins/vps/locale"))
11
12 def _(txt):
13         t = gettext.dgettext("vps", txt)
14         if t == txt:
15                 t = gettext.gettext(txt)
16         return t
17
18 localeInit()
19 language.addCallback(localeInit)