Opened 5 years ago

Closed 5 years ago

#22120 closed New feature (fixed)

No documentation on how to explicitly set user language

Reported by: Sasha Romijn Owned by: Sasha Romijn
Component: Translations Version: master
Severity: Normal Keywords: nlsprint14
Cc: eromijn@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In some cases, it is desirable to set the language for a current session directly. For example, I have a project where the user's language preference is recorded in some API. django.utils.translation.activate() will only change this for the current thread. There is no documented way to modify the language for the entire session.

This is not at all difficult - simply setting request.SESSION['_language'] suffices for most cases, or otherwise modifying the cookie. This is essentially what the set_language() view already does. In the interest of cleanliness, it would be best if we no longer hardcode the _language key for this, but define this somewhere.

Change History (4)

comment:1 Changed 5 years ago by Sasha Romijn

Cc: eromijn@… added
Has patch: set

comment:2 Changed 5 years ago by Bas Peschier

Triage Stage: UnreviewedReady for checkin

Good cleanup of _language, clear language and nothing breaks.

comment:3 Changed 5 years ago by Sasha Romijn

Owner: changed from nobody to Sasha Romijn
Status: newassigned

comment:4 Changed 5 years ago by Baptiste Mispelon <bmispelon@…>

Resolution: fixed
Status: assignedclosed

In 8cd32f09659cc271050a62b978f244b8a3445315:

Fixed #22120 -- Documented persistent activation of languages and cleaned up language session key use

Note: See TracTickets for help on using tickets.
Back to Top