Plugins-Meta: rework plugin meta files and prepare for inclusion into enigma2 transla...
[enigma2-plugins.git] / partnerbox / src / __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("Partnerbox", resolveFilename(SCOPE_PLUGINS, "Extensions/Partnerbox/locale"))
11
12 def _(txt):
13         t = gettext.dgettext("Partnerbox", txt)
14         if t == txt:
15                 print "[Partnerbox] fallback to default translation for", txt
16                 t = gettext.gettext(txt)
17         return t
18
19 localeInit()
20 language.addCallback(localeInit)
21