Fixed #5241 -- Kept active transalation in LocaleMiddleware.process_response.
This commit is contained in:
parent
06de130dae
commit
aa089b106b
|
@ -51,7 +51,7 @@ class LocaleMiddleware(object):
|
||||||
request.is_secure() and 'https' or 'http',
|
request.is_secure() and 'https' or 'http',
|
||||||
request.get_host(), language, request.get_full_path())
|
request.get_host(), language, request.get_full_path())
|
||||||
return HttpResponseRedirect(language_url)
|
return HttpResponseRedirect(language_url)
|
||||||
translation.deactivate()
|
|
||||||
if not (self.is_language_prefix_patterns_used()
|
if not (self.is_language_prefix_patterns_used()
|
||||||
and language_from_path):
|
and language_from_path):
|
||||||
patch_vary_headers(response, ('Accept-Language',))
|
patch_vary_headers(response, ('Accept-Language',))
|
||||||
|
|
|
@ -1096,3 +1096,26 @@ class MultipleLocaleActivationTests(TestCase):
|
||||||
t = Template("{% load i18n %}{% blocktrans %}No{% endblocktrans %}")
|
t = Template("{% load i18n %}{% blocktrans %}No{% endblocktrans %}")
|
||||||
with translation.override('nl'):
|
with translation.override('nl'):
|
||||||
self.assertEqual(t.render(Context({})), 'Nee')
|
self.assertEqual(t.render(Context({})), 'Nee')
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
USE_I18N=True,
|
||||||
|
LANGUAGES=(
|
||||||
|
('en', 'English'),
|
||||||
|
('fr', 'French'),
|
||||||
|
),
|
||||||
|
MIDDLEWARE_CLASSES=(
|
||||||
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
class LocaleMiddlewareTests(TestCase):
|
||||||
|
|
||||||
|
urls = 'i18n.urls'
|
||||||
|
|
||||||
|
def test_streaming_response(self):
|
||||||
|
# Regression test for #5241
|
||||||
|
response = self.client.get('/fr/streaming/')
|
||||||
|
self.assertContains(response, "Oui/Non")
|
||||||
|
response = self.client.get('/en/streaming/')
|
||||||
|
self.assertContains(response, "Yes/No")
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
|
from django.http import StreamingHttpResponse
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
urlpatterns = i18n_patterns('',
|
||||||
|
(r'^streaming/$', lambda r: StreamingHttpResponse([_("Yes"), "/", _("No")])),
|
||||||
|
)
|
Loading…
Reference in New Issue