Opened 13 years ago

Closed 8 years ago

Last modified 8 years ago

#15143 closed New feature (fixed)

Document how to set the language for the test client

Reported by: Claude Paroz Owned by: Michael Scott
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Paul Oswald Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I suggest to add a note in the documentation about how to set the language for the test client.

Without the LocaleMiddleware, it's possible to set it with the activate/deactivate functions from django.utils.translation.

When LocaleMiddleware is activated, another method has to be used, otherwise the settings.LANGUAGE_CODE is always used. I've been able to set the language by passing HTTP_ACCEPT_LANGUAGE='de' to the get/post method, or by loading a cookie (client.cookies.load({settings.LANGUAGE_COOKIE_NAME:'de'})).

Change History (12)

comment:1 by Ramiro Morales, 13 years ago

Triage Stage: UnreviewedAccepted

BTW, the activate/deactivate functions from django.utils.translation aren't documented either.

comment:2 by Paul Oswald, 13 years ago

Cc: Paul Oswald added

comment:3 by Łukasz Rekucki, 13 years ago

Severity: Normal
Type: New feature

comment:4 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Tim Graham, 8 years ago

Easy pickings: set
Summary: Add precisions about setting the language for the test clientDocument how to set the language for the test client
Version: 1.2master

Looks like this could go in the test client documentation at docs/topics/testing/tools.txt.

comment:7 by Michael Scott, 8 years ago

Owner: changed from nobody to Michael Scott
Status: newassigned

I'm interested in contributing to Django and have been advised to start with some of the 'easy pickings' tasks, so I'll try picking up this issue to get started.

comment:8 by Michael Scott, 8 years ago

I've made the proposed changes to the testing tools topic documentation and pushed it to the branch https://github.com/mscott250/django/tree/ticket_15143 . I think the text looks suitable and I've included examples of the different ways to set the language.

I've created a pull request for the branch as the contributing docs say to do, it's available here https://github.com/django/django/pull/7233 . Please let me know if you think the text can be improved in any way or if there is anything else I need to do for this contribution.

Cheers,
Michael

comment:9 by Simon Charette, 8 years ago

Has patch: set
Patch needs improvement: set

comment:10 by Michael Scott, 8 years ago

Patch needs improvement: unset

Thanks for the feedback Simon, I've addressed all the items you mentioned and after fighting with Git a little bit I've created another pull request here https://github.com/django/django/pull/7238 .

Please let me know if there's any further improvements I can make to it or if there's anything else to do for this.

comment:11 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 3c447b10:

Fixed #15143 -- Doc'd how to set the language for the test client.

comment:12 by Tim Graham <timograham@…>, 8 years ago

In 416004c:

[1.10.x] Fixed #15143 -- Doc'd how to set the language for the test client.

Backport of 3c447b108ac70757001171f7a4791f493880bf5b from master

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