Opened 2 years ago
Closed 2 years ago
#35009 closed Bug (duplicate)
set_language doesn't work with prefix_default_language=False
| Reported by: | KILLIAN.arts | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | 4.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Using set_language, without setting the next parameter in the request, doesn't redirect to the default language when prefix_default_language=False in i18n_patterns(). If prefix_default_language=True, and I manually enter the page with the default language code in the url one time after setting prefix_default_language=True, set_language will redirect to and from the default language as expected.
{% get_current_language as CURRENT_LANGUAGE_CODE %} {% get_available_languages as AVAILABLE_LANGUAGES %} {% get_language_info_list for AVAILABLE_LANGUAGES as languages %} {% for lang in languages %} {% if lang.code != CURRENT_LANGUAGE_CODE %} <form id="language-switcher" action="{% url 'set_language' %}" method="post"> {% csrf_token %} <input name="language" type="hidden" value="{{ lang.code }}"> <button type="submit">{{ lang.name_local }}</button> </form> {% endif %} {% endfor %}
urlpatterns = i18n_patterns( path('admin/', admin.site.urls), path('', include('core.urls')), path('contact/', include('contact.urls')), path('articles/', include('articles.urls')), prefix_default_language=False, ) urlpatterns += [path("i18n/", include("django.conf.urls.i18n")),]
Note:
See TracTickets
for help on using tickets.
I just tried set_language with a fresh install and it has the same issue.