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)
Change History (6)
by , 17 years ago
Attachment: | 6326_tests.diff added |
---|
comment:1 by , 17 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
comment:2 by , 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 , 17 years ago
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
fix for the test case (same as in bug description)