[Django] #28070: set_language (i18n) without next does not change language if called from a language prefixed URL

21 views
Skip to first unread message

Django

unread,
Apr 11, 2017, 11:15:16 AM4/11/17
to django-...@googlegroups.com
#28070: set_language (i18n) without next does not change language if called from a
language prefixed URL
-------------------------------------+-------------------------------------
Reporter: Monsieur | Owner: nobody
Cellophane |
Type: Bug | Status: new
Component: | Version: 1.11
Internationalization | Keywords: set_language, url
Severity: Normal | translation
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Greetings.

**Preamble**:
Switching language by posting to set_language with an empty next parameter
causes a redirection to the REFERER url, as per the documentation.

**Description**:

What this means is that if language selection is made from a language-
neutral URL (say /about/), selecting english as language the redirection
in set_language will land the user to /en/about.

If - however - a new language selection (say de) is now made from
/en/about/, the landing spot will be (again) /en/about, rather than the
expected /de/about; the new language is now, however, memorised in the
user's session.

**What should happen:**
Invoking set_language from a language prefixed page with an empty next
parameter should redirect to the language-neutral URL, allowing the
session based url selection to kick in.

**What would help:**

Of course, being able to reference the current language-neutral url as the
next parameter to set_language would achieve the result. However,
language-neutral urls aren't availble in templates (or anywhere I looked);
so one's best hope is writing a custom template filter that strips the
language prefix from a URL and hen use the stripped request.path o
request.get_fulL_path as the next parameter to the POST.

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

Django

unread,
Apr 12, 2017, 3:29:40 AM4/12/17
to django-...@googlegroups.com
#28070: set_language (i18n) without next does not change language if called from a
language prefixed URL
-------------------------------------+-------------------------------------
Reporter: Monsieur Cellophane | Owner: nobody

Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: set_language, url | Triage Stage:
translation | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Monsieur Cellophane:

Old description:

> Greetings.
>
> **Preamble**:
> Switching language by posting to set_language with an empty next
> parameter causes a redirection to the REFERER url, as per the
> documentation.
>
> **Description**:
>
> What this means is that if language selection is made from a language-
> neutral URL (say /about/), selecting english as language the redirection
> in set_language will land the user to /en/about.
>
> If - however - a new language selection (say de) is now made from
> /en/about/, the landing spot will be (again) /en/about, rather than the
> expected /de/about; the new language is now, however, memorised in the
> user's session.
>
> **What should happen:**
> Invoking set_language from a language prefixed page with an empty next
> parameter should redirect to the language-neutral URL, allowing the
> session based url selection to kick in.
>
> **What would help:**
>
> Of course, being able to reference the current language-neutral url as
> the next parameter to set_language would achieve the result. However,
> language-neutral urls aren't availble in templates (or anywhere I
> looked); so one's best hope is writing a custom template filter that
> strips the language prefix from a URL and hen use the stripped
> request.path o request.get_fulL_path as the next parameter to the POST.

New description:

Greetings.

**Preamble**:
Switching language by posting to set_language with an empty next parameter
causes a redirection to the REFERER url, as per the documentation.

**Description**:

What this means is that if language selection is made from a language-
neutral URL (say /about/), selecting english as language the redirection
in set_language will land the user to /en/about.

If - however - a new language selection (say de) is now made from
/en/about/, the landing spot will be (again) /en/about, rather than the

expected **/de/about**. The new language (de) is now, however, memorised


in the user's session.

**What should happen:**
Invoking set_language from a language prefixed page with an empty ''next''
parameter should redirect to the language-neutral URL, allowing the
session based url selection to kick in.

**What would help:**

Of course, being able to reference the current language-neutral url as the
''next'' parameter to set_language would achieve the result. However,
language-neutral urls aren't availble in templates (or anywhere I looked);
so one's best hope is writing a custom template filter that strips the

language prefix from a URL and hen use the stripped request.path (or
request.get_fulL_path) as the ''next'' parameter to the POST.

--

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

Django

unread,
Jun 2, 2017, 9:44:05 AM6/2/17
to django-...@googlegroups.com
#28070: set_language (i18n) without next does not change language if called from a
language prefixed URL
-------------------------------------+-------------------------------------
Reporter: Monsieur Cellophane | Owner: nobody

Type: Bug | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: set_language, url | Triage Stage:
translation | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

This should have been fixed by #24122 / [aa5ab114e34645]. Isn't it the
same issue? Did we miss something?

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

Django

unread,
Jun 3, 2017, 6:53:16 AM6/3/17
to django-...@googlegroups.com
#28070: set_language (i18n) without next does not change language if called from a
language prefixed URL
-------------------------------------+-------------------------------------
Reporter: Monsieur Cellophane | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution: needsinfo

Keywords: set_language, url | Triage Stage:
translation | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

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


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

Reply all
Reply to author
Forward
0 new messages