{% trans %} does not support render array and MarkupInterface valued placeholders

Created on 7 September 2014, over 10 years ago
Updated 18 April 2025, 8 days ago

Problem/Motivation

Noticed in #2226493: Apply formatters and widgets to Node base fields . Right now you get warnings and errors.

Right now {% trans %} only allows strings to be passed in and using render arrays is not possible. Being able to use render arrays in node.html.twig would allow us to simplify template_preprocess_node().

Proposed resolution

Change this line:
$compiler->string($token->getAttribute('placeholder'))->raw(' => ')->subcompile($token)->raw(', ');
in TwigNodeTrans.php

API changes

Allows common values to be rendered in Trans tag.

Before

After

📌 Task
Status

Needs work

Version

11.0 🔥

Component

theme system

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024