Ticket #17319: 17319.patch
File 17319.patch, 1.3 KB (added by , 13 years ago) |
---|
-
docs/topics/i18n/translation.txt
1231 1231 .. function:: set_language(request) 1232 1232 1233 1233 As a convenience, Django comes with a view, :func:`django.views.i18n.set_language`, 1234 that sets a user's language preference and redirects back to the previous page. 1234 that sets a user's language preference and redirects to a given URL, of by default, 1235 back to the previous page. 1235 1236 1236 1237 Activate this view by adding the following line to your URLconf:: 1237 1238 … … 1260 1261 1261 1262 <form action="/i18n/setlang/" method="post"> 1262 1263 {% csrf_token %} 1263 <input name="next" type="hidden" value=" /next/page/" />1264 <input name="next" type="hidden" value="{{ redirect_to }}" /> 1264 1265 <select name="language"> 1265 1266 {% get_language_info_list for LANGUAGES as languages %} 1266 1267 {% for language in languages %} … … 1270 1271 <input type="submit" value="Go" /> 1271 1272 </form> 1272 1273 1274 In this example, Django looks up the URL of the page to which the user will be 1275 redirected in the ``redirect_to`` context variable. 1276 1273 1277 Using translations outside views and templates 1274 1278 ---------------------------------------------- 1275 1279