Opened 17 years ago

Closed 17 years ago

#6326 closed (fixed)

fix test case for _() in templates, improve documentation

Reported by: Antti Kaihola Owned by: nobody
Component: Internationalization Version: dev
Severity: Keywords:
Cc: 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

[source:django/trunk/tests/regressiontests/templates/tests.py#6996#L739 the Test case for using the _() construct in templates] is invalid and doesn't actually test the feature at all:

'i18n10': ('{{ bool|yesno:_("ja,nein") }}', {'bool': True}, 'ja'),

This should be better, and it does pass:

'i18n10': ('{{ bool|yesno:_("yes,no,maybe") }}', {'bool': True, 'LANGUAGE_CODE': 'de'}, 'Ja'),

Also, the documentation for using _() in templates could clarify that |yesno:_("yes,no") used in the example actually looks for the string "yes,no" in the translation files, not for "yes" and "no" separately.

It would be better to use an actual existing translation string like "yes,no,maybe" instead of "yes,no" in the example.

Attachments (2)

6326_tests.diff (782 bytes ) - added by Antti Kaihola 17 years ago.
fix for the test case (same as in bug description)
6326_docs.diff (846 bytes ) - added by Antti Kaihola 17 years ago.
suggested improvement for documentation

Download all attachments as: .zip

Change History (6)

by Antti Kaihola, 17 years ago

Attachment: 6326_tests.diff added

fix for the test case (same as in bug description)

by Antti Kaihola, 17 years ago

Attachment: 6326_docs.diff added

suggested improvement for documentation

comment:1 by Simon Greenhill <dev@…>, 17 years ago

Has patch: set
Triage Stage: UnreviewedReady for checkin

comment:2 by Malcolm Tredinnick, 17 years ago

I'm not going to apply the documentation patch, since it's very fragile for somebody's code to rely on what is a "standard" Django string. That will change from time to time. They will pick up things they mark for translation in their own app translation file.

However, a clarification about the whole string being looked up should go in. I'll fix that.

comment:3 by Malcolm Tredinnick, 17 years ago

(In [7059]) Clarified that filter arguments are passed as a single string to the translation support. Refs #6326.

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [7060]) Fixed #6326 -- Made the test for translations of filter arguments test something that has a chance of failure. Thanks akaihola.

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