diff options
author | jpope <jpope@jpope.org> | 2014-01-05 16:55:58 -0600 |
---|---|---|
committer | jpope <jpope@jpope.org> | 2014-01-05 16:55:58 -0600 |
commit | 0172ad000148f1cfe6f5110982c364f46b3d0ecb (patch) | |
tree | a32f97b2cc6fa6fb41de8263f8c6136922e87799 /mediagoblin/tools | |
parent | 1e298b10c7cba2d27cb19f1aee03134f66ef6e20 (diff) | |
parent | 64eab630bf99e4d92e567628dbfc7cecf4cc27c4 (diff) | |
download | mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.lz mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.xz mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.zip |
Merge remote-tracking branch 'upstream/master' into skeletongobblin
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r-- | mediagoblin/tools/template.py | 5 | ||||
-rw-r--r-- | mediagoblin/tools/translate.py | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index fa290611..e5acdf45 100644 --- a/mediagoblin/tools/template.py +++ b/mediagoblin/tools/template.py @@ -26,7 +26,9 @@ from mediagoblin import mg_globals from mediagoblin import messages from mediagoblin import _version from mediagoblin.tools import common +from mediagoblin.tools.translate import is_rtl from mediagoblin.tools.translate import set_thread_locale +from mediagoblin.tools.translate import get_locale_from_request from mediagoblin.tools.pluginapi import get_hook_templates, hook_transform from mediagoblin.tools.timesince import timesince from mediagoblin.meddleware.csrf import render_csrf_form_token @@ -72,12 +74,13 @@ def get_jinja_env(template_loader, locale): # ... fetch all waiting messages and remove them from the queue # ... construct a grid of thumbnails or other media # ... have access to the global and app config + # ... determine if the language is rtl or ltr template_env.globals['fetch_messages'] = messages.fetch_messages template_env.globals['app_config'] = mg_globals.app_config template_env.globals['global_config'] = mg_globals.global_config template_env.globals['version'] = _version.__version__ template_env.globals['auth'] = mg_globals.app.auth - + template_env.globals['is_rtl'] = is_rtl(locale) template_env.filters['urlencode'] = url_quote_plus # add human readable fuzzy date time diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index b20e57d1..f55ce349 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -31,6 +31,12 @@ AVAILABLE_LOCALES = None TRANSLATIONS_PATH = pkg_resources.resource_filename( 'mediagoblin', 'i18n') +# Known RTL languages +KNOWN_RTL = set(["ar", "fa", "zh","he","iw","ja","ur","yi","ji"]) + +def is_rtl(lang): + """Returns true when the local language is right to left""" + return lang in KNOWN_RTL def set_available_locales(): """Set available locales for which we have translations""" |