summaryrefslogtreecommitdiff
path: root/lib/i18n.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2019-07-04 10:51:22 -0400
committerGitHub <noreply@github.com>2019-07-04 10:51:22 -0400
commit32548e8e51d13d511813ba4e2a4571bd73e440e5 (patch)
treea5c1d8e8932048f6f4c02d55e144023fa82b2e8f /lib/i18n.py
parent4db305a36dd87dc9fc21034571eaebb078054bd3 (diff)
parentc51ae9ccb7052e4015b4a3dd3e2817d8625e3ab0 (diff)
lettering features (#399)
lettering features
Diffstat (limited to 'lib/i18n.py')
-rw-r--r--lib/i18n.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/i18n.py b/lib/i18n.py
index 98f63ec1..f57bbf9c 100644
--- a/lib/i18n.py
+++ b/lib/i18n.py
@@ -1,7 +1,9 @@
-import sys
+import gettext
import os
from os.path import dirname, realpath
-import gettext
+import sys
+
+from .utils import cache
_ = translation = None
locale_dir = None
@@ -33,5 +35,27 @@ def localize(languages=None):
_ = translation.ugettext
+@cache
+def get_languages():
+ """return a list of languages configured by the user
+
+ I really wish gettext provided this as a function. Instead, we've duplicated
+ its code below.
+ """
+
+ languages = []
+
+ for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
+ val = os.environ.get(envar)
+ if val:
+ languages = val.split(':')
+ break
+
+ if 'C' not in languages:
+ languages.append('C')
+
+ return languages
+
+
_set_locale_dir()
localize()