[FanControl2] typo, readme, webif-init
[enigma2-plugins.git] / fancontrol2 / src / __init__.py
1 from Components.Language import language\r
2 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE\r
3 import os,gettext\r
4 \r
5 PluginLanguageDomain = "FanControl2"\r
6 PluginLanguagePath = "Extensions/FanControl2/locale"\r
7 \r
8 def localeInit():\r
9     lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"\r
10     os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!\r
11 #    print "[" + PluginLanguageDomain + "] set language to ", lang\r
12     gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))\r
13 \r
14 def _(txt):\r
15     t = gettext.dgettext(PluginLanguageDomain, txt)\r
16     if t == txt:\r
17  #       print "[" + PluginLanguageDomain + "] fallback to default translation for ", txt\r
18         t = gettext.gettext(txt)\r
19     return t\r
20 \r
21 localeInit()\r
22 language.addCallback(localeInit)\r