I've spent hours trying to find a language selection form to include in my base template and wish there would be a built in template tag (ex. {% language_selector %} ).
For a non developer like me, it's hard to implement this, so I believe that if a language selection tag was included in Wagtail, it would be a welcomed addition.
Django's sample language selector works but would need some javascript or something else so we don't have to click on a 'GO' button. Also there is no checking whether or not we are using i18n_patterns for the URLs. And there are other things that could be automated, drop down menu for more than 2 languages, simple link which toggle between two languages, etc., and possible options.
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language" onclick="Bonjour">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
Wagtail is a great CMS. With time, there will be better multilingual built in functionality. I am using wagtail-modeltranslation, which works well for me, but I need to let the users swith langues on the website and this has proven to be much more challenging than expected, since I would need to do some coding. I believe that this is something that could be built in (ex. a template tag) or at least to have some examples in the documentation.
Thank you!
:+1:
I have the same issue,
Currently, I am trying to implemented internationalization using wagtail-modeltranslation, and added the code that adding a "language code" at the beginning of url in url.py.
however, I do not know how to put a swicher on the navbar.
I hope someone can teach me this solution.
Most helpful comment
I have the same issue,
Currently, I am trying to implemented internationalization using wagtail-modeltranslation, and added the code that adding a "language code" at the beginning of url in url.py.
however, I do not know how to put a swicher on the navbar.
I hope someone can teach me this solution.