It might be that you just want a link to the current page in another language. If you need that, see my comment here: http://stackoverflow.com/questions/11437454/django-templates-get-current-url-in-another-language/21573776#21573776
On Tuesday, 15 April 2008 01:03:56 UTC+1, Simon Tite wrote:
-- On Tuesday, 15 April 2008 01:03:56 UTC+1, Simon Tite wrote:
The documentation on how the user can change the language of a page/
site (from: http://www.djangoproject.com/documentation/i18n/ ), in the
section "The set_language redirect view", gives the following code:
<code>
<form action="/i18n/setlang/" method="post">
<input name="next" type="hidden" value="/next/page/" />
<select name="language">
{% for lang in LANGUAGES %}
<option value="{{ lang.0 }}">{{ lang.1 }}</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
</code>
This of course means the user has to click on the language required,
then click the submit button. The result is put in POST data, and then
the redirect to " /i18n/setlang/" does its magic, then returns you
back to the page you came from, with the new LANGUAGE_CODE set up
correctly and, (here's the magic), the code is also automatically
stored in the user's session and cookie data, providing useful
persistence.
However, instead of clicking on submit, I would prefer the user to
click on just a regular link, so I nead to write something like..
<code>
<a href="/i18n/setlang?lang=fr&name=next>Click here for French</a>
</code>
which means it will use GET data.
The documentation says that redirect to set_language uses POST data,
so I guess my question could be rephrased as: How do I use a simple
link to send POST data to the page I am linking to? And I guess that
maybe this is not a Django-related question at all!
Still, maybe one of you kind people can help me or at least point me
in the right direction.
Thanks, Simon.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d0263684-5ccc-4f8e-9a77-6b31ce60d9f3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment