Django

Code

Ticket #6326 (closed: fixed)

Opened 7 months ago

Last modified 6 months ago

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

Reported by: akaihola Assigned to: nobody
Milestone: Component: Internationalization
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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

6326_tests.diff (0.8 kB) - added by akaihola on 01/06/08 05:27:00.
fix for the test case (same as in bug description)
6326_docs.diff (0.8 kB) - added by akaihola on 01/06/08 05:59:54.
suggested improvement for documentation

Change History

01/06/08 05:27:00 changed by akaihola

  • attachment 6326_tests.diff added.

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

01/06/08 05:59:54 changed by akaihola

  • attachment 6326_docs.diff added.

suggested improvement for documentation

01/13/08 06:29:48 changed by Simon Greenhill <dev@simon.net.nz>

  • needs_better_patch changed.
  • has_patch set to 1.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • needs_docs changed.

02/02/08 19:43:50 changed by mtredinnick

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.

02/02/08 19:49:35 changed by mtredinnick

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

02/02/08 19:49:55 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #6326 (fix test case for _() in templates, improve documentation)




Change Properties
Action