Opened 2 years ago

Closed 20 months ago

#21417 closed Bug (fixed)

use TEMPLATE_STRING_IF_INVALID format string in blocktrans

Reported by: keturn Owned by: Claude Paroz <claude@…>
Component: Template system Version: 1.6
Severity: Normal 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


ticket:19915 makes it so that TEMPLATE_STRING_IF_INVALID may show when template strings fail inside blocktrans blocks. It doesn't, however, treat that as a format string in the way that FilterExpression.resolve does (as is described in the documentation).

Change History (5)

comment:1 Changed 23 months ago by chrismedrela

  • Component changed from Uncategorized to Template system
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

To reproduce:

  • set TEMPLATE_STRING_IF_INVALID = "Invalid(%s)"
  • run python shell and type:
from django.template import Template, Context
t = Template("""{% load i18n %}
    Outside: {{ missing }}
    {% blocktrans %}Inside: {{ missing }}{% endblocktrans %}""")
>>>    Outside: Invalid(missing)
>>>    Inside: Invalid(%s)

Missing variables in blocktrans tag are handled here: It should work the same like FilterExpression.resolve.

comment:2 Changed 23 months ago by claudep

  • Owner changed from nobody to claudep
  • Status changed from new to assigned

comment:3 Changed 23 months ago by claudep

  • Has patch set
  • Owner claudep deleted
  • Status changed from assigned to new

comment:4 Changed 20 months ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 20 months ago by Claude Paroz <claude@…>

  • Owner set to Claude Paroz <claude@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 02add43568b694ef25afeae474b5b1da883826c6:

Fixed #21417 -- Expanded TEMPLATE_STRING_IF_INVALID in blocktrans

Thanks keturn for the reporti, Chris Medrela for details and
Tim Graham for the review.
Refs #19915.

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