﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6325	fix test case for _() in templates, improve documentation	Antti Kaihola	nobody	"The {{{_()}}} construct available for templates doesn't work [http://www.djangoproject.com/documentation/i18n/#in-template-code as explained in the documentation], and there are no actual unit tests for it either.

Here is a test script to illustrate the problem:
{{{
from django.conf import settings
settings.configure(LANGUAGE_CODE='fi')

from django.template import Template, Context

template = Template(
    u'{% load i18n %}'
    u'{% trans ""Yes"" %} '
    u'{{ true|yesno:_(""Yes,No"") }} '
    u'{{ false|yesno:_(""Yes,No"") }}')

context = Context({'true': True, 'false': False})
print template.render(context)
}}}
This should print out the Finnish translation of ""Yes"" twice and ""No"" once:
{{{
Kyllä Kyllä Ei
}}}
but only {{{ {% trans %} }}} works correctly, and the script in fact prints
{{{
Kyllä Yes No
}}}


There's [source:django/trunk/tests/regressiontests/templates/tests.py#6996#L739 a test case] which probably is meant to test this, but fails to do so:
{{{
'i18n10': ('{{ bool|yesno:_(""ja,nein"") }}', {'bool': True}, 'ja'),
}}}
I assume this is what was intended:
{{{
'i18n10': ('{{ bool|yesno:_(""Yes,No"") }}', {'bool': True, 'LANGUAGE_CODE': 'de'}, 'Ja'),
}}}
and it currently fails:
{{{
Template test (TEMPLATE_STRING_IF_INVALID='INVALID'): i18n10 -- FAILED. Expected 'Ja', got u'Yes'
}}}"		closed	Internationalization	dev		invalid			Unreviewed	0	0	0	0	0	0
