Problem/Motivation
In #1927584: Add support for the Twig {% trans %} tag extension we added support for {{trans}} blocks, but this lacks context, so we cannot do something like:
{% trans %}
{{ month }}
{% endtrans %}
vs.
{{ month|t([],'Long month name') }}
or
{% set module_name = 'views' %}
{% trans %}
Provided by {{ module_name }}
{% endtrans %}
vs.
'Provided by @views'|t({'@views':module_name}, 'module name') }}
Proposed resolution
Add an optional parameter with the context that makes this cleaner, so we can write:
{% trans context 'Long month name' %}
{{ month }}
{% endtrans %}
or
{% trans context 'module name'%}
Provided by {{'views'}}
{% endtrans %}
Completed Tasks
- None
Remaining Tasks (@todo after commit)
- Get feedback from Twig experts
Discuss about if we should propose this to Twig i18n, so we don't differ on syntax from them#1- Get a working patch!
- Update documentation.
- Update {{trans}} change notification.