[Django] #33668: i18n set_language not working in Safari

60 views
Skip to first unread message

Django

unread,
Apr 28, 2022, 8:15:49 AM4/28/22
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
------------------------------------------------+------------------------
Reporter: yopiti | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 4.0
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 |
------------------------------------------------+------------------------
Trying to implement a session / cookie based translation selector.

This code correctly sets the language in Chrome (100) & Firefox (99.0.1),
but not in Safari (15.4).

{% load i18n %}

<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
{% 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>

Request is made, its redirected to /i18n/setlang/ and back to the original
page, but not switching language.

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

Django

unread,
Apr 28, 2022, 8:16:07 AM4/28/22
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
-------------------------------------+-------------------------------------

Reporter: yopiti | Owner: nobody
Type: Bug | Status: new
Component: | Version: 4.0
Internationalization |
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
-------------------------------------+-------------------------------------
Description changed by yopiti:

Old description:

> Trying to implement a session / cookie based translation selector.
>
> This code correctly sets the language in Chrome (100) & Firefox (99.0.1),
> but not in Safari (15.4).
>
> {% load i18n %}
>
> <form action="{% url 'set_language' %}" method="post">{% csrf_token %}
> <input name="next" type="hidden" value="{{ redirect_to }}" />
> <select name="language">
> {% 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>
>
> Request is made, its redirected to /i18n/setlang/ and back to the
> original page, but not switching language.

New description:

Trying to implement a session / cookie based translation selector.

This code correctly sets the language in Chrome (100) & Firefox (99.0.1),
but not in Safari (15.4).


{{{
{% load i18n %}

<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
{% 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>

}}}

Request is made, its redirected to /i18n/setlang/ and back to the original
page, but not switching language.

--

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

Django

unread,
Apr 28, 2022, 9:25:58 AM4/28/22
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
-------------------------------------+-------------------------------------
Reporter: yopiti | Owner: nobody
Type: Bug | Status: new
Component: | Version: 4.0
Internationalization |
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 Carlton Gibson):

This might be the intelligent tracking protection — it doesn't send the
cookies after a-certain-number of redirects. 🤔

Can I ask: if you refresh, is the language then-set? This sometimes
happens with logins, but when I've seen it, the login has worked, it's
just that the cookie wasn't sent for the final redirect request, and so
refreshing then sends it.

Was this working previously? Or are you only implementing it now? (Not
sure if this is something we'd be able to work around... — short of Use
less internal redirects... 🤔)

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

Django

unread,
Apr 28, 2022, 9:33:07 AM4/28/22
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
--------------------------------------+------------------------------------

Reporter: yopiti | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* cc: Carlton Gibson (added)
* stage: Unreviewed => Accepted


Comment:

I'm going to Accept as
[https://docs.djangoproject.com/en/4.0/topics/i18n/translation/#the-set-
language-redirect-view The set_language redirect view docs] have this
exact form, so we'll need to review if a note or such is needed even if we
can't suggest a different flow.

--
Ticket URL: <https://code.djangoproject.com/ticket/33668#comment:3>

Django

unread,
Jan 23, 2023, 5:55:46 AM1/23/23
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
-------------------------------------+-------------------------------------
Reporter: yopiti | Owner: Eknath
| Baravkar
Type: Bug | Status: assigned
Component: | Version: 4.0
Internationalization |

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Eknath Baravkar):

* owner: nobody => Eknath Baravkar
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33668#comment:4>

Django

unread,
Jan 27, 2026, 1:30:30 AM (10 days ago) Jan 27
to django-...@googlegroups.com
#33668: i18n set_language not working in Safari
-------------------------------------+-------------------------------------
Reporter: yopiti | Owner: James
| Beard
Type: Bug | Status: assigned
Component: | Version: 4.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by James Beard):

* owner: Eknath Baravkar => James Beard

Comment:

Tried unsuccessfully to reproduce this behaviour with a minimal app using
the form markup mentioned. Changing the language and submitting the form
did save the requested language to django_language cookie using Safari and
other browsers.

Test app used Python 3.8 and Django 4.0.10. Only had Safari 15.6 to test
with, so tried with 14.1.3 as well with the cookie still being saved
successfully.

Without further info it's impossible to know how "but not switching
language" was determined. For example, if was just that the drop down
didn't change that could have been caused by a string mismatch when
deciding which option to mark selected.

If nothing noted by original reporter or anyone else in a month or so plan
to resolve as "works for me".
--
Ticket URL: <https://code.djangoproject.com/ticket/33668#comment:5>
Reply all
Reply to author
Forward
0 new messages