summaryrefslogtreecommitdiff
path: root/lib/i18n.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2019-04-02 23:07:38 -0400
committerLex Neva <github.com@lexneva.name>2019-04-02 23:07:38 -0400
commita6a86973dd54d623394fdbfc61e6e4c0ca263cc0 (patch)
tree2d9c48e16e3d6ca82729a758815d8205d658d1da /lib/i18n.py
parenta9cf553066c3fd5b907593751bb00f77f32ce86a (diff)
add localization for font names and descriptions
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()