-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
28 lines (21 loc) · 896 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- coding: utf-8 -*-
from __future__ import print_function
from Components.Language import language
from Tools.Directories import resolveFilename, SCOPE_PLUGINS
import os
import gettext
PluginLanguageDomain = "AutoBouquets"
PluginLanguagePath = "Extensions/AutoBouquets/locale"
def localeInit():
lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
print("[" + PluginLanguageDomain + "] set language to ", lang)
gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
def _(txt):
t = gettext.dgettext(PluginLanguageDomain, txt)
if t == txt:
# print("[" + PluginLanguageDomain + "] fallback to default translation for", txt)
t = txt
return t
localeInit()
language.addCallback(localeInit)