Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Updated: Comment #N
Problem/Motivation
#2160365: Date field required marker rendered as "Array" brought up that it's pretty easy to end up with "Array" on the page when using trans tags. We should at least make this more obvious. Trans tags are by design only meant to deal with simple variables, mostly strings.
Proposed resolution
Expand the exception handling in the trans token parser to throw an exception for arrays/render arrays. See \Drupal\Core\Template\TwigTransTokenParser::checkTransString() for the existing error handling.
Remaining tasks
- Patch
- Tests
- Patch review
User interface changes
n/a
API changes
Not really an API change, just a DX improvement.
Comments
Comment #1
star-szrExpand problem/motivation slightly and link to change record for trans tags.
Comment #2
lauriii#2334319: {% trans %} does not support render array and MarkupInterface valued placeholders