Review main Merged

93016[FEATURE] Translate defaultValue of form elements

Josua Vogel CR +2 V +2 Hard +528 −36 updated 03/17/26, 05:51

Commit message

The TYPO3 Form Framework now translates the `defaultValue` property
of form elements before rendering, using the same XLF translation
mechanism already in place for `label`, `placeholder` and other
properties.

A new PSR-14 event listener `TranslateDefaultValueBeforeRendering`
listens to `BeforeRenderableIsRenderedEvent` and delegates to the
existing `TranslationService::translateFormElementValue()` method.
The `TranslationService` is extended to resolve the `defaultValue`
directly via `FormElementInterface::getDefaultValue()`, consistent
with how `label` is handled.

If no translation is found, the original value from the form
definition is kept unchanged. Translation errors (e.g. missing
site/language configuration in CLI context) are silently swallowed
to avoid breaking the rendering pipeline.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 2

Files 8

Review log 1825

  1. Josua Vogel uploaded patch set 1 02/26/26, 14:45

  2. Josua Vogel marked it work in progress 02/26/26, 14:45

  3. core-ci voted on patch set 1 V +1 02/26/26, 14:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96929

  4. Josua Vogel uploaded patch set 2 V +1 03/03/26, 08:38

  5. Josua Vogel marked it ready for review 03/03/26, 08:38

  6. core-ci voted on patch set 2 V -1 03/03/26, 08:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97158

  7. Josua Vogel commented on patch set 3 V -1 03/03/26, 09:05

    Published edit on patch set 2.
  8. core-ci voted on patch set 3 V +1 03/03/26, 09:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97163

  9. Josua Vogel updated the commit message in patch set 4 V +1 03/03/26, 12:49

  10. core-ci voted on patch set 4 V +1 03/03/26, 12:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97177

  11. Josua Vogel rebased onto patch set 5 V +1 03/10/26, 15:03

  12. core-ci voted on patch set 5 V +1 03/10/26, 15:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97706

  13. Garvin Hicking commented on patch set 5 03/14/26, 16:45

    Feature-97637-TranslateDefaultValueOfFormElements.rst:54

    It would help to have an example that actually "translates", like: identifier: bestDish label: 'Best dish?' defaultValue: 'Hamburger' and then have an example for `de.locallang.xlf` (not just locallang.xlf) with: identifier: bestDish label: 'Lieblingsgericht' defaultValue: 'Kartoffel'

    TranslateDefaultValueBeforeRendering.php:28

    Whole class can be readonly?

    TranslationServiceTest.php:548

    If we try, we can fit Hamlet in here!
  14. Garvin Hicking commented on patch set 5 03/14/26, 16:48

    Feature-97637-TranslateDefaultValueOfFormElements.rst:53

    I think the form definition example above should also hold the `contact-form` identifier to understand how this mapping comes across
  15. Garvin Hicking voted on patch set 5 V +1 03/14/26, 17:04

  16. Josua Vogel uploaded patch set 6 V +1 03/16/26, 14:49

  17. Josua Vogel commented on patch set 6 03/16/26, 14:50

    Feature-97637-TranslateDefaultValueOfFormElements.rst:53 Reply

    Done

    Feature-97637-TranslateDefaultValueOfFormElements.rst:54 Reply

    Done

    TranslateDefaultValueBeforeRendering.php:28 Reply

    Done

    TranslationServiceTest.php:548 Reply

    Done
  18. core-ci voted on patch set 6 V +1 03/16/26, 14:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/98023

  19. Garvin Hicking commented on patch set 6 03/16/26, 17:44

    Feature-97637-TranslateDefaultValueOfFormElements.rst:57

    Why is "/Form/" gone here? The yaml references the subdir...?
  20. Josua Vogel commented on patch set 7 V +1 03/16/26, 19:21

    Published edit on patch set 6.
  21. Josua Vogel commented on patch set 7 03/16/26, 19:22

    Feature-97637-TranslateDefaultValueOfFormElements.rst:57 Reply

    Incorrectly adjusted 😄
  22. core-ci voted on patch set 7 V +1 03/16/26, 19:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/98044

  23. Garvin Hicking voted on patch set 7 CR +1 V +1 03/16/26, 20:17

  24. Georg Ringer voted on patch set 7 CR +2 V +2 03/17/26, 05:51

  25. Georg Ringer merged patch set 8 03/17/26, 05:51