its mandatory to call deleteDialog for the pip screen
[enigma2-plugins.git] / epgrefresh / 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 PluginLanguageDomain = "EPGRefresh"
8 PluginLanguagePath = "Extensions/EPGRefresh/locale"
9 # Fallback to EN for Code-Strings
10 DefaultPluginLang = "EN"
11
12 def localeInit():
13         lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
14         os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
15         gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
16
17 def _(txt):
18         t = gettext.dgettext(PluginLanguageDomain, txt)
19         if t == txt:
20                 t = getDefaultTxt(txt)
21                 if t == txt:
22                         t = gettext.gettext(txt)
23         return t
24
25 def getDefaultTxt(txt):
26         lang = language.getLanguage()[:2]
27         os_environ["LANGUAGE"] = DefaultPluginLang
28         t = gettext.dgettext(PluginLanguageDomain, txt)
29         os_environ["LANGUAGE"] = lang
30         return t
31
32 localeInit()
33 language.addCallback(localeInit)
34
35 STARTNOTIFICATIONID = 'EpgRefreshStartNotificationId'
36 ENDNOTIFICATIONID = 'EpgRefreshEndNotificationId'
37 NOTIFICATIONDOMAIN = "EPGRefresh"