summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-02-16 12:13:48 +0000
committerJannis Leidel <jannis@leidel.info>2010-02-16 12:13:48 +0000
commit71da5f62dab825e015864fd5604be46815e24ff1 (patch)
treedf85588638d9c5c683ac18ec862cc87917dfb58c /django
parente50eefceb6be7c074c3b48bc802fb766c22d25f2 (diff)
Fixed #7720 - Fallback to the base language if the sub language given in the language cookie doesn't exist. Thanks, djoume and Ramiro Morales.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12442 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/utils/translation/trans_real.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 3f13d79290..42e3bcc0d7 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -356,6 +356,10 @@ def get_language_from_request(request):
return lang_code
lang_code = request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME)
+
+ if lang_code and lang_code not in supported:
+ lang_code = lang_code.split('-')[0] # e.g. if fr-ca is not supported fallback to fr
+
if lang_code and lang_code in supported and check_for_language(lang_code):
return lang_code