Skip to content

Commit fdbb930

Browse files
committed
Example and note with usage of trimmed option in blocktrans
1 parent 6f02839 commit fdbb930

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/i18n.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ filters or accessing object attributes. You can't do that within the ``{%
147147
blocktrans %}`` block, so you need to bind the expression to a local variable
148148
first::
149149

150-
{% blocktrans with revision.created_date|timesince as timesince %}
150+
{% blocktrans trimmed with revision.created_date|timesince as timesince %}
151151
{{ revision }} {{ timesince }} ago
152152
{% endblocktrans %}
153153

@@ -157,13 +157,20 @@ first::
157157
counter with the name ``count`` and provide a plural translation after the ``{%
158158
plural %}`` tag::
159159

160-
{% blocktrans with amount=article.price count years=i.length %}
160+
{% blocktrans trimmed with amount=article.price count years=i.length %}
161161
That will cost $ {{ amount }} per year.
162162
{% plural %}
163163
That will cost $ {{ amount }} per {{ years }} years.
164164
{% endblocktrans %}
165165

166166

167+
.. note::
168+
169+
The previous multi-lines examples also use the ``trimmed`` option.
170+
This remove newline characters and replace any whitespace at the beginning and end of a line,
171+
helping translators when translating these strings.
172+
173+
167174
Strings in Python
168175
-----------------
169176

0 commit comments

Comments
 (0)