[ShowClock]Initial checkin
[enigma2-plugins.git] / showclock / 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 import os,gettext
6  
7 PluginLanguageDomain = "ShowClock"
8 PluginLanguagePath = "Extensions/ShowClock/locale"
9  
10 def localeInit():
11     lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
12     os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
13     #print "[WebInterface] set language to ", lang
14     gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
15  
16 def _(txt):
17     t = gettext.dgettext(PluginLanguageDomain, txt)
18     if t == txt:
19         #print "[%s] fallback to default translation for %s" %(PluginLanguageDomain, txt)
20         t = gettext.gettext(txt)
21     return t
22  
23 localeInit()
24 language.addCallback(localeInit)