I'm using i18n_patterns
to create language prefixes in a Django app.
My URLs look like this:
/de/contact/
/fr/contact/
/it/contact/
In my base template, I'm looping over all available languages to show the language switch links.
{% get_available_languages as languages %}
<nav id="language_chooser">
<ul>
{% for lang_code, lang_name in languages %}
{% language lang_code %}
<li><a href="{% url 'home' %}" alt="{{ lang_name }}" title="{{ lang_name }}">{{ lang_code }}</a></li
{% endlanguage %}
{% endfor %}
</ul>
</nav>
In this case, I'm reversing the "home" URL. Is there a way to get a translated URL of the current page instead?
If I'm on the German version of my "contact" page, I want the "fr" link to point to the French version of the "contact" page, not to the "home" page.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…