Skip to content

Example and note with usage of trimmed option in blocktrans #4479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ filters or accessing object attributes. You can't do that within the ``{%
blocktrans %}`` block, so you need to bind the expression to a local variable
first::

{% blocktrans with revision.created_date|timesince as timesince %}
{% blocktrans trimmed with revision.created_date|timesince as timesince %}
{{ revision }} {{ timesince }} ago
{% endblocktrans %}

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

{% blocktrans with amount=article.price count years=i.length %}
{% blocktrans trimmed with amount=article.price count years=i.length %}
That will cost $ {{ amount }} per year.
{% plural %}
That will cost $ {{ amount }} per {{ years }} years.
{% endblocktrans %}


.. note::

The previous multi-lines examples also use the ``trimmed`` option.
This removes newline characters and replaces any whitespace at the beginning and end of a line,
helping translators when translating these strings.


Strings in Python
-----------------

Expand Down