Reputation: 2066
I've got a problem with using django's {% trans %} template function. I have values translated in my messages file and it gets translated in some cases. But not all of them.
I'm trying to debug the issue. I have a block of code like this - in which I'm iterating through form's fields and outputting them:
<tr>
<td>{{ hdr_data|safe }} {% trans row_field.label_tag %}</td>
<td>{{ row_field }}</td>
<td>{{ row_field.errors}}</td>
</tr>
If we suppose that I want to print _row_field.label_tag_ for string "ABC", which I have translated to "ZXF" the above code still prints "ABC". However if I do sth like this:
<tr>
<td>{{ hdr_data|safe }} {% trans 'ABC' %}</td>
<td>{{ row_field }}</td>
<td>{{ row_field.errors}}</td>
</tr>
The translation is ok - I get "ZXF".
I've been trying to check what's wrong with that label_tag, and it actually is this string:
<label for="id_abc">ABC</label>
Shouldn't it be just "ABC"? Isn't this the cause of my problems? If so, why sometimes it works and sometimes not?
My django version is 1.2.1.
Upvotes: 0
Views: 563
Reputation: 12214
field.label_tag
wraps your label inside a <label> tag
. To just get the text, use field.label
. This is explained here.
Upvotes: 1