Review main Merged

94328[BUGFIX] Ensure correct TS overrides for labels

Markus Klein CR +2 V +2 Easy +40 −8 updated 07/03/26, 15:06

Commit message

The current implementation had several flaws, which are all fixed now.

1.) The assumption, that labels not having a translation
in the target language, will adhere to a TS override for the default
language is wrong. This would have to be applied for all
languages in the fallback chain, which is not possible
in the current code structure. We don't know which language
in the fallback chain contributed a value.

2.) LanguageService::getTypo3LanguageKey returns "en"
if a proper EN locale is present. This needs special
treatment in the overrides calculation, because there
"default" and "en" are actually the same.

3.) The LanguageService::overrideLabels array used a
completely wrong data structure, which made the array
override with the data structure from the XLF files
completely useless. Things only worked, because TS overrides where
inherited within the overrides from default, which covered a lot of
cases by accident.
This is also the reason, why the fixed bug actually occurred.

This change now fixes those flaws, aligns the test assumptions and adds
phpstan info too, for better understanding.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1521

  1. Markus Klein uploaded patch set 1 06/04/26, 21:24

  2. core-ci voted on patch set 1 V -1 06/04/26, 21:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102985

  3. Markus Klein uploaded patch set 2 V -1 06/04/26, 21:41

  4. core-ci voted on patch set 2 V -1 06/04/26, 21:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102987

  5. Markus Klein uploaded patch set 3 V -1 06/04/26, 23:21

  6. core-ci voted on patch set 3 V -1 06/04/26, 23:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102990

  7. Markus Klein uploaded patch set 4 V -1 06/04/26, 23:35

  8. Markus Klein uploaded patch set 5 06/04/26, 23:42

  9. core-ci voted on patch set 4 V -1 06/04/26, 23:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102993

  10. core-ci voted on patch set 5 V -1 06/04/26, 23:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/102994

  11. Markus Klein rebased onto patch set 6 V -1 06/05/26, 07:15

  12. core-ci voted on patch set 6 V +1 06/05/26, 07:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/103012

  13. Benni Mack voted on patch set 6 CR +1 06/08/26, 05:51

  14. Christian Kuhn commented on patch set 6 CR +1 V +1 06/09/26, 22:36

    And the v13 version looks good, too.
  15. Stefan Bürk voted on patch set 6 CR +1 V +1 06/10/26, 09:31

  16. Christian Kuhn voted on patch set 6 CR +2 V +2 06/10/26, 09:37

  17. Christian Kuhn merged patch set 7 06/10/26, 09:53

  18. Ayke Halder commented on patch set 7 06/27/26, 09:46

    May we declutter the code for current main? * Reverse some of these changes here. * Change and merge 92466: [Bugfix] Localize labels with intermediate locale for undefined locale | https://review.typo3.org/c/Packages/TYPO3.CMS/+/92466
  19. Markus Klein commented on patch set 7 06/27/26, 20:40

    Reply

    Not sure what you mean with "Reverse some changes". Cleanup/declutter is always welcome, I'd say.
  20. Ayke Halder commented on patch set 7 07/03/26, 13:43

    Reply

    @markus.klein@typo3.org I provided more context where this patch here works against core language overlay logics. Where-as the other patch (Change and merge 92466: [Bugfix] Localize labels with intermediate locale for undefined locale | https://review.typo3.org/c/Packages/TYPO3.CMS/+/92466) further enforces core logics. That said, I'll change my patch to have the new test-cases from this patch here working - and keeping a clear core logic: * There is no human language `default` - only `en`. * Outside core components must never use langauge `default`.

    LanguageService.php:434

    `overrideLabels()` is a public function which is called from outside ̀sysext/core`. The outside-core perspective has no language ̀default` anymore. Only human languages like `en`, `de-AT` are in use. So any deprecated call for `default` must immediately be converted to the proper human language `en` here. ---- The inside-core perspective has a `default` language layer (I'd better call it `base`-layer) as there are the `base`-language files provided by each extension. (The `base`-language file of course are in human language 'english': But still this is the `base`-layer and there is also an additional `en`-layer.) In-core fallback path for human language `en`: `en` -> `base` In-core fallback path for human language `de-AT`: `de-AT` -> `de` -> `en` -> `base` (Having `en` in the `de-AT` fallback path is by historical implementation - might get thrown out in the future or kept as is.)
  21. Markus Klein commented on patch set 7 07/03/26, 15:06

    Reply

    Any improvement is welcome. I'm glad we have now have tests the first time in history, that properly document that label override via TS actually works. Feel free to get rid of "default" completely in main. This will probably help us getting rid of a lot of hacks.

    LanguageService.php:434 Reply

    I bet the average user/integrator is not even aware that `en` is not equal `default/base`. The fallback was only created as a compatibility layer. So, I highly doubt that anyone would even notice when `en` would vanish from the aforementioned `de-AT` chain.