summaryrefslogtreecommitdiffstats
path: root/pykolab/translate.py
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab/translate.py')
-rw-r--r--pykolab/translate.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pykolab/translate.py b/pykolab/translate.py
index ce9e406..7bac219 100644
--- a/pykolab/translate.py
+++ b/pykolab/translate.py
@@ -26,10 +26,18 @@ import gettext
import os
N_ = lambda x: x
-_ = lambda x: current.lgettext(x)
+
+# This function as such may, at times, cause tracebacks.
+#_ = lambda x: current.lgettext(x)
current = gettext.translation(domain, fallback=True)
+def _(x):
+ try:
+ return current.lgettext(x)
+ except Exception, errmsg:
+ return x
+
def getDefaultLangs():
languages = []
for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
@@ -46,11 +54,15 @@ def getDefaultLangs():
for nelang in gettext._expand_lang(lang):
if nelang not in nelangs:
nelangs.append(nelang)
+
return nelangs
def setUserLanguage(lang):
global current
+ if not len(lang.split('.')) > 1 and not lang.endswith('.UTF-8'):
+ lang = "%s.UTF-8" % (lang)
+
langs = []
for l in gettext._expand_lang(lang):
if l not in langs: