Ticket #17319: 17319.patch

File 17319.patch, 1.3 KB (added by Aymeric Augustin, 12 years ago)
  • docs/topics/i18n/translation.txt

     
    12311231.. function:: set_language(request)
    12321232
    12331233As 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.
     1234that sets a user's language preference and redirects to a given URL, of by default,
     1235back to the previous page.
    12351236
    12361237Activate this view by adding the following line to your URLconf::
    12371238
     
    12601261
    12611262    <form action="/i18n/setlang/" method="post">
    12621263    {% csrf_token %}
    1263     <input name="next" type="hidden" value="/next/page/" />
     1264    <input name="next" type="hidden" value="{{ redirect_to }}" />
    12641265    <select name="language">
    12651266    {% get_language_info_list for LANGUAGES as languages %}
    12661267    {% for language in languages %}
     
    12701271    <input type="submit" value="Go" />
    12711272    </form>
    12721273
     1274In this example, Django looks up the URL of the page to which the user will be
     1275redirected in the ``redirect_to`` context variable.
     1276
    12731277Using translations outside views and templates
    12741278----------------------------------------------
    12751279
Back to Top