Fix some wrong locale path definitions and disable own locale handling inside Network...
[enigma2-plugins.git] / setpasswd / src / __init__.py
1 # -*- coding: ISO-8859-1 -*-
2
3 from Components.Language import language
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
5 import os,gettext
6 PluginLanguageDomain = "SetPasswd"
7 PluginLanguagePath = "SystemPlugins/SetPasswd/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 "[SetPasswd] set language to ", 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 "[SetPasswd] fallback to default translation for", txt
19                 t = gettext.gettext(txt)
20         return t
21
22 localeInit()
23 language.addCallback(localeInit)
24