AutomaticTimerlistCleanup plugin - initial checkin
[vuplus_dvbapp-plugin] / automatictimerlistcleanup / src / __init__.py
diff --git a/automatictimerlistcleanup/src/__init__.py b/automatictimerlistcleanup/src/__init__.py
new file mode 100644 (file)
index 0000000..2bad5d8
--- /dev/null
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+from os import environ as os_environ
+import gettext
+
+def localeInit():
+       lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+       os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+       gettext.bindtextdomain("AutomaticTimerlistCleanup", resolveFilename(SCOPE_PLUGINS, "SystemPlugins/AutomaticTimerlistCleanup/locale"))
+
+def _(txt):
+       t = gettext.dgettext("AutomaticTimerlistCleanup", txt)
+       if t == txt:
+               print "[AutomaticTimerlistCleanup] fallback to default translation for", txt
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()
+language.addCallback(localeInit)
+