By joelpittet on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.2.x
Introduced in version:
11.2.5
Issue links:
Description:
Summary
The Twig translation tag, {% trans %}, works with rendered expressions ({{ }}) that return render arrays and MarkupInterface objects. Previously, only rendered expressions returning scalar values could be used inside {% trans %} tags, and other types of values would cause warnings or errors.
The following will work:
// Example render array variable built in a preprocess.
$variables['render_array'] = [
'#prefix' => '<b>',
'#markup' => 'render array in a trans tag',
'#suffix' => '</b>',
];
In the Twig template which is provided the render_array variable.
{% trans %}
This is a {{ render_array }}.
{% endtrans %}
Impacts:
Module developers
Themers