Review main Work in progress

92336[WIP][FEATURE] Add Factory for TranslatorInterface

Benni Mack CR 0 V -1 Hard +400 −33 updated 11/10/26, 14:25

Commit message

Building on top of "TranslatorInterface" this adds
the best practice on how to inject a preconfigured
translator. This is the old message below, but just
for reference:
----
It can be injected in any controller, and then be used
instead of $GLOBALS[LANG].

The main method "translate()" is prepared to also
deal with plurals, default values and alternative locales.

The second method "label()" is used where only have one full
string (like we know from "sL") like in TCA, or TypoScript,
but with the possibility of arguments, default value
and a custom locale.

What is necessary:
- Factory: We should do something like Locales->createFromRequest()
  We should probably use a cache + keeping the instances.
- We should consider a "combined identifier" logic
  for strings in TCA and TypoScript in the interface?
  see the problem in LinkValidatorController.
- We need plurals, and overriding the locale as well.
- We should think about TypoScript overrides as well?

More todos:
- Consider to use this for replacing LocalizationUtility as well
- Consider to use this for using in f:translate as well
- How can we distinguish Extbase/Fluid in FE vs. BE?
- We might introduce a "LocaleAspect" with a "ContentLocale" and a "SystemLabelLocale" and a "SystemLocale"?

Finally we'd have an answer for
- getting rid of $GLOBALS[LANG]
- a superior API for LocalizationUtility

and that'd be more than enough.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 5
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/36/92336/5 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/36/92336/5 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V -1 Blocked
    • core-ci -1 CI

Merge conflicts 14

Files 6

Review log 611

  1. Benni Mack uploaded patch set 1 01/14/26, 20:15

  2. Benni Mack marked it work in progress 01/14/26, 20:15

  3. core-ci voted on patch set 1 V -1 01/14/26, 20:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/93475

  4. Benni Mack uploaded patch set 2 V -1 02/05/26, 10:11

  5. core-ci voted on patch set 2 V -1 02/05/26, 10:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95126

  6. Benni Mack updated the commit message in patch set 3 V -1 02/05/26, 19:27

  7. core-ci voted on patch set 3 V -1 02/05/26, 19:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/95204

  8. Benni Mack uploaded patch set 4 V -1 04/02/26, 09:02

  9. core-ci voted on patch set 4 V -1 04/02/26, 09:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99459

  10. Benni Mack updated the commit message in patch set 5 V -1 11/10/26, 14:10

  11. core-ci voted on patch set 5 V -1 11/10/26, 14:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113908