[Django] #35009: set_language doesn't work with prefix_default_language=False

10 views
Skip to first unread message

Django

unread,
Nov 30, 2023, 5:07:10 PM11/30/23
to django-...@googlegroups.com
#35009: set_language doesn't work with prefix_default_language=False
-----------------------------------------+------------------------
Reporter: killianarts | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

{{{#!django
{% 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 %}
}}}

{{{#!python
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")),]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35009>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 1, 2023, 8:50:32 PM12/1/23
to django-...@googlegroups.com
#35009: set_language doesn't work with prefix_default_language=False
-------------------------------+--------------------------------------
Reporter: KILLIAN.arts | Owner: nobody

Type: Bug | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by KILLIAN.arts):

I just tried set_language with a fresh install and it has the same issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/35009#comment:1>

Django

unread,
Dec 3, 2023, 11:43:06 PM12/3/23
to django-...@googlegroups.com
#35009: set_language doesn't work with prefix_default_language=False
-------------------------------+--------------------------------------
Reporter: KILLIAN.arts | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #28567.

--
Ticket URL: <https://code.djangoproject.com/ticket/35009#comment:2>

Reply all
Reply to author
Forward
0 new messages