Add eParted plugin from IHAD
[enigma2-plugins.git] / eparted / src / locale.py
1 # -*- coding: utf-8 -*-
2 from Components.Language import language
3 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
4 from os import environ as os_environ
5 import gettext
6
7 PluginLanguageDomain = "eParted"
8 PluginLanguagePath = "Extensions/eParted/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 PluginLanguageDomain, "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 PluginLanguageDomain, "fallback to default translation for", txt
20                 t = gettext.gettext(txt)
21         return t
22
23 localeInit()
24 language.addCallback(localeInit)
25