Code

Ticket #18700: 18700b.diff

File 18700b.diff, 2.0 KB (added by DrMeers, 21 months ago)

Forgot quotes

Line 
1diff --git a/django/conf/urls/i18n.py b/django/conf/urls/i18n.py
2index 6e56af8..7f2fc23 100644
3--- a/django/conf/urls/i18n.py
4+++ b/django/conf/urls/i18n.py
5@@ -1,5 +1,5 @@
6 from django.conf import settings
7-from django.conf.urls import patterns
8+from django.conf.urls import patterns, url
9 from django.core.urlresolvers import LocaleRegexURLResolver
10 
11 def i18n_patterns(prefix, *args):
12@@ -16,5 +16,5 @@ def i18n_patterns(prefix, *args):
13 
14 
15 urlpatterns = patterns('',
16-    (r'^setlang/$', 'django.views.i18n.set_language'),
17+    url(r'^setlang/$', 'django.views.i18n.set_language', name='setlang'),
18 )
19diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
20index 988948e..40ba93c 100644
21--- a/docs/topics/i18n/translation.txt
22+++ b/docs/topics/i18n/translation.txt
23@@ -1272,7 +1272,7 @@ Here's example HTML template code:
24 
25 .. code-block:: html+django
26 
27-    <form action="/i18n/setlang/" method="post">
28+    <form action="{% url 'setlang' %}" method="post">
29     {% csrf_token %}
30     <input name="next" type="hidden" value="{{ redirect_to }}" />
31     <select name="language">
32diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py
33index 9993ae9..c5b45b8 100644
34--- a/tests/regressiontests/views/tests/i18n.py
35+++ b/tests/regressiontests/views/tests/i18n.py
36@@ -5,6 +5,7 @@ import gettext
37 from os import path
38 
39 from django.conf import settings
40+from django.core.urlresolvers import reverse
41 from django.test import TestCase
42 from django.utils.translation import override, activate, get_language
43 from django.utils.text import javascript_quote
44@@ -23,6 +24,9 @@ class I18NTests(TestCase):
45             self.assertRedirects(response, 'http://testserver/views/')
46             self.assertEqual(self.client.session['django_language'], lang_code)
47 
48+    def test_setlang_reversal(self):
49+        self.assertEqual(reverse('setlang'), '/views/i18n/setlang/')
50+
51     def test_jsi18n(self):
52         """The javascript_catalog can be deployed with language settings"""
53         saved_lang = get_language()