Opened 11 years ago
Closed 11 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: | dev |
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 by , 11 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
Good cleanup of _language, clear language and nothing breaks.
comment:3 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
PR created: https://github.com/django/django/pull/2345