source: ipk/source.sh4/swapepg_crossepg/var/swap/extensions/CrossEPG/crossepg_locale.py@ 13478

Last change on this file since 13478 was 7451, checked in by BPanther, 15 years ago

[ipk] - copy source->source.sh4

File size: 889 bytes
Line 
1from Components.Language import language
2from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
3
4import os,gettext
5
6PluginLanguageDomain = "CrossEPG"
7PluginLanguagePath = "SystemPlugins/CrossEPG/po"
8
9def 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 "[CrossEPG] set language to ", lang
13 gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
14 gettext.bindtextdomain('enigma2', resolveFilename(SCOPE_LANGUAGE, ""))
15
16def _(txt):
17 t = gettext.dgettext(PluginLanguageDomain, txt)
18 if t == txt:
19 #print "[CrossEPG] fallback to default translation for", txt
20 t = gettext.dgettext('enigma2', txt)
21 return t
22
23
24localeInit()
25language.addCallback(localeInit)
Note: See TracBrowser for help on using the repository browser.