[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Use fallback languages
commit 7bde75e2a89c0bdeceed567643d467ce3846ab56
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Thu Jun 27 17:46:13 2013 +0200
Use fallback languages
---
lib/bridgedb/HTTPServer.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index 380439a..c181d63 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -282,9 +282,13 @@ def setLocaleFromRequestHeader(request):
localedir=os.path.join(os.path.dirname(__file__), 'i18n/')
if langs:
- langs = filter(lambda x: re.match('^[a-z_]{1,5}$', x), langs)
+ langs = filter(lambda x: re.match('^[a-z\-]{1,5}$', x), langs)
logging.debug("Languages: %s" % langs)
- map(lambda x: x.replace("-","_").lower(),langs)
+ # add fallback languages
+ langs_only = filter(lambda x: '-' in x, langs)
+ langs.extend(map(lambda x: x.split('-')[0], langs_only))
+ # gettext wants _, not -
+ map(lambda x: x.replace('-', '_'), langs)
lang = gettext.translation("bridgedb", localedir=localedir,
- languages=langs, fallback=True)
+ languages=langs, fallback=True)
lang.install(True)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits