Add Persian localization. Thanks to Mehdi and Persian Prince
[enigma2-plugins.git] / weatherplugin / src / __init__.py
1 # -*- coding: utf-8 -*-
2 from Components.Language import language
3 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
4 import os,gettext
5
6 def localeInit():
7         lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
8         os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
9         gettext.bindtextdomain("WeatherPlugin", resolveFilename(SCOPE_PLUGINS, "Extensions/WeatherPlugin/locale"))
10
11 def _(txt):
12         t = gettext.dgettext("WeatherPlugin", txt)
13         if t == txt:
14                 print "[WeatherPlugin] fallback to default translation for", txt
15                 t = gettext.gettext(txt)
16         return t
17
18 localeInit()
19 language.addCallback(localeInit)