summaryrefslogtreecommitdiff
path: root/pykolab/translate.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-07-07 11:21:27 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-07-07 11:21:27 (GMT)
commitcf500d4b24cf865d77bf09e2bf149da2cf09421a (patch)
tree573b342d3fa620b61339639254cba5220623b8d6 /pykolab/translate.py
parent2dd455c056baad1acc059273645ddf696027b2c8 (diff)
downloadpykolab-cf500d4b24cf865d77bf09e2bf149da2cf09421a.tar.gz
Add function to change user language; add en.po for English localization
Diffstat (limited to 'pykolab/translate.py')
-rw-r--r--pykolab/translate.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/pykolab/translate.py b/pykolab/translate.py
index bee8fc2..85f4516 100644
--- a/pykolab/translate.py
+++ b/pykolab/translate.py
@@ -28,6 +28,8 @@ import os
N_ = lambda x: x
_ = lambda x: gettext.ldgettext(domain, x)
+#gettext.bindtextdomain(domain, '/usr/local/share/locale')
+
def getDefaultLangs():
languages = []
for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
@@ -45,3 +47,17 @@ def getDefaultLangs():
if nelang not in nelangs:
nelangs.append(nelang)
return nelangs
+
+def setUserLanguage(lang):
+ langs = []
+ for l in gettext._expand_lang(lang):
+ if l not in langs:
+ langs.append(l)
+
+ try:
+ translation = gettext.translation(domain, languages=langs)
+ translation.install()
+ except:
+ return False
+
+ return True