Closed Bug 1226592 Opened 9 years ago Closed 8 years ago

ditch fe jinja2 filter and use Jinja2 newstyle gettext instead

Categories

(Mozilla QA Graveyard :: One and Done, defect, P3)

Version 4
defect

Tracking

(Not tracked)

RESOLVED WONTFIX
Milestone 1

People

(Reporter: bsilverberg, Unassigned)

Details

+++ This bug was initially created as a clone of Bug #1222040 +++

Fjord has an fe (format escaped) filter that we inherited from Tower that allows us to do the following in templates:

    {{ _('Response: {id}')|fe(id=response.id) }}


In this expression, gettext is called with the msgid "Response: {id}" and it returns a translated form of that string. The resulting string is marked as Jinja2-safe by Fjord's adjusted gettext, so nothing is escaped in this string.

Then the string is passed to the fe filter which evaluates response.id in the context, escapes that value and then interpolates it into the string using Python's .format().

Yay! This is what we want!

However, there are two problems.

1. fe requires that we use python-brace-format (e.g. {}) variables which
   we want to get rid of (bug #1220657)

2. Jinja2's newstyle gettext already does this:

   {{ _('Response: %(id)s', id=response.id) }}


Here's a more complex example.

With fe:

   <h2>{{ _('<b>Response id: {id}</b>')|fe(id='<i>102</i>') }}</h2>

This comes out as:

   <b>Response id: &lt;i&gt;102&lt;/i&gt;</b>

where the <b> </b> is not escaped and the <i> </i> are.

The equivalent with newstyle gettext:

   <h2>{{ _('<b>Response id: %(id)s</b>', id='<i>102</i>') }}</h2>

produces the same thing.


This bug covers getting rid of our fe filter in favor of Jinja2's newstyle gettext.
No longer blocks: 1220657
No longer depends on: 1222040, 1218381
Priority: -- → P3
Target Milestone: --- → Milestone 3
Target Milestone: Milestone 3 → Milestone 1
Version: Version 3 → Version 4
Project is being retired.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.