wagtailwagtail-localize

How to make user to select content language dynamicaly in wagtail template?


I am using "wagtail_localize.locales" for language translation and multi-language support

Wagtail version: wagtail==3.0.3

Using code from official documentation https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#i18n-basic-example

{% for language_code, language_name in LANGUAGES %}
{% get_language_info for language_code as lang %}

{% language language_code %}
    <a href="{% pageurl page.localized %}" rel="alternate" hreflang="{{ language_code }}">
        {{ lang.name_local }}
    </a>
{% endlanguage %}
{% endfor %}

This code is not working


Solution

  • To use the get_language_info tag, you'll need {% load i18n %} at the top of your template.