Issue Feature Under Review

#111697Translate messages of Symfony constraints with the catalogues of symfony/validator

Alexander Schnitzler 12/01/26, 18:21 updated 12/01/26, 18:58

Description

Since #111687 a violation of a Symfony constraint shows a readable message in Extbase forms, but always the English one. The message catalogues that symfony/validator ships (validators.<locale>.xlf) are not used, so an integrator has to write an own label for every constraint to get a localized message.

Goal

A Symfony constraint on a model property yields a message in the language of the current request without any own label:

#[Assert\Length(max: 80)]
protected string $title = '';
  • German frontend: “Diese Zeichenkette ist zu lang. Sie sollte höchstens 80 Zeichen haben.”
  • A message that is a TYPO3 label reference keeps working as today and wins over the Symfony catalogue.
  • Plural forms are chosen for the locale of the request.
  • Without a request (CLI) the message stays English.

Notes

  • ConstraintDecoratingValidator is the only place that turns violations into Extbase errors today.
  • Constraint validators must not receive the request for this. The locale is passed explicitly to the translator.
  • Needs a test through a real request that asserts the rendered text in two languages.

Part of #111686.

Reviews 1

History 01

  1. Gerrit Code Review pushed patch set 1 for main to change 98268 status New Under Review 12/01/26, 18:58