mirror of https://github.com/django/django.git
Fixed #17555 -- Added support for a missing trailing slash when redirecting based on the browser language. Thanks, neaf.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17443 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
878cc62bd4
commit
ef4d84d11a
|
@ -38,7 +38,7 @@ accept_language_re = re.compile(r'''
|
|||
(?:\s*,\s*|$) # Multiple accepts per header.
|
||||
''', re.VERBOSE)
|
||||
|
||||
language_code_prefix_re = re.compile(r'^/([\w-]+)/')
|
||||
language_code_prefix_re = re.compile(r'^/([\w-]+)(/|$)')
|
||||
|
||||
def to_locale(language, to_lower=False):
|
||||
"""
|
||||
|
|
|
@ -793,6 +793,18 @@ class MiscTests(TestCase):
|
|||
r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
|
||||
self.assertEqual(g(r), 'zh-cn')
|
||||
|
||||
def test_get_language_from_path(self):
|
||||
from django.utils.translation.trans_real import get_language_from_path as g
|
||||
self.assertEqual(g('/pl/'), 'pl')
|
||||
self.assertEqual(g('/pl'), 'pl')
|
||||
self.assertEqual(g('/xyz/'), None)
|
||||
|
||||
def test_get_language_from_path(self):
|
||||
from django.utils.translation.trans_null import get_language_from_path as g
|
||||
self.assertEqual(g('/pl/'), None)
|
||||
self.assertEqual(g('/pl'), None)
|
||||
self.assertEqual(g('/xyz/'), None)
|
||||
|
||||
def test_percent_in_translatable_block(self):
|
||||
extended_locale_paths = settings.LOCALE_PATHS + (
|
||||
os.path.join(here, 'other', 'locale'),
|
||||
|
|
Loading…
Reference in New Issue