initial commit of the new teletext plugin
[enigma2-plugins.git] / teletext / src / __init__.py
1 from Components.Language import language
2 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
3
4 import os,gettext
5
6 PluginLanguageDomain = "TeleText"
7 PluginLanguagePath = "Extensions/TeleText/locale"
8
9 def localeInit():
10         lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
11         os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
12         print "[%s] set language to [%s]" % (PluginLanguageDomain, lang)
13         gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
14  
15 def _(txt):
16         t = gettext.dgettext(PluginLanguageDomain, txt)
17         if t == txt:
18                 print "[%s] fallback to default translation for %s" %(PluginLanguageDomain, txt)
19                 t = gettext.gettext(txt)
20         return t
21
22 def _log(message):
23   print "[TeleText]", message
24   
25 def _debug(message):
26   d=open("/tmp/dbttcp.log","a")
27   d.write("[TeleText] %s\n" % message)
28   d.close()
29
30 localeInit()
31 language.addCallback(localeInit)