diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-04-03 12:11:54 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-04-04 10:54:16 +0200 |
| commit | 7a0d9b5cda04c74287e052f1b4ebdf869e53ff0f (patch) | |
| tree | d088d6294e0224340454429c00f0bb55da8c8263 /django | |
| parent | 426b63ba04521b8eaffb129b7e4feca36eed8777 (diff) | |
Fixed #24569 -- Made some translation functions accept None value
get_language() can return None when translations are deactivated.
Thanks Nicola Peduzzi for the reporti and Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/translation/trans_real.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 2d86f46786..a7a89f9bd5 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -248,8 +248,12 @@ def get_language_bidi(): * False = left-to-right layout * True = right-to-left layout """ - base_lang = get_language().split('-')[0] - return base_lang in settings.LANGUAGES_BIDI + lang = get_language() + if lang is None: + return False + else: + base_lang = get_language().split('-')[0] + return base_lang in settings.LANGUAGES_BIDI def catalog(): @@ -394,7 +398,7 @@ def check_for_language(lang_code): <https://www.djangoproject.com/weblog/2007/oct/26/security-fix/>. """ # First, a quick check to make sure lang_code is well-formed (#21458) - if not language_code_re.search(lang_code): + if lang_code is None or not language_code_re.search(lang_code): return False for path in all_locale_paths(): if gettext_module.find('django', path, [to_locale(lang_code)]) is not None: |
