reduce ammount of try/except-blocks used,
[vuplus_dvbapp-plugin] / autotimer / src / __init__.py
1 # -*- coding: utf-8 -*-
2
3 from Components.Language import language
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
5 from os import environ as os_environ
6 import gettext
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 "[AutoTimer] set language to ", lang
12     gettext.bindtextdomain("AutoTimer", resolveFilename(SCOPE_PLUGINS, "Extensions/AutoTimer/locale"))
13
14 def _(txt):
15     t = gettext.dgettext("AutoTimer", txt)
16     if t == txt:
17         print "[AutoTimer] fallback to default translation for", txt
18         t = gettext.gettext(txt)
19     return t
20
21 localeInit()
22 language.addCallback(localeInit)
23