def activateLanguage(self, index):
try:
if index not in self.lang:
print "Selected language %s does not exist, fallback to en_EN!" % index
index = "en_EN"
lang = self.lang[index]
print "Activating language " + lang[0]
self.catalog = gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[index])
self.catalog.install(names=("ngettext", "pgettext"))
self.activeLanguage = index
for x in self.callbacks:
x()
except:
print "Error in activating language!"
# NOTE: we do not use LC_ALL, because LC_ALL will not set any of the categories, when one of the categories fails.
# We'd rather try to set all available categories, and ignore the others
for category in [locale.LC_CTYPE, locale.LC_COLLATE, locale.LC_TIME, locale.LC_MONETARY, locale.LC_MESSAGES, locale.LC_NUMERIC]:
try:
locale.setlocale(category, (self.getLanguage(), 'UTF-8'))
except:
pass
# HACK: sometimes python 2.7 reverts to the LC_TIME environment value, so make sure it has the correct value
os.environ["LC_TIME"] = self.getLanguage() + '.UTF-8'
#os.environ["GST_SUBTITLE_ENCODING"] = self.getGStreamerSubtitleEncoding()
评论列表
文章目录