Review main Merged

95443[BUGFIX] Resolve locale dependencies in LanguageServiceFactory

Benjamin Kott CR +2 V +2 Normal +67 −9 updated 10/16/26, 14:14

Commit message

LanguageServiceFactory::create() resolved the dependencies of a locale
given as string, but used a Locale object as is. A Locale built through
its constructor - as SiteLanguage does - does not carry a resolved
dependency list, so "da-DK" never fell back to "da" and label lookup
dropped straight to English.

This affected every caller handing over a Locale object, such as
LocalizationUtility::translate(), the form TranslationService and the
PageRenderer. createFromSiteLanguage() worked around it by casting the
locale to string.

A Locale without resolved dependencies is now resolved through the
Locales factory, while one carrying dependencies is honoured as is, so
custom locales keep working. createFromSiteLanguage() no longer needs
the string cast.

Review

  • Code review CR +2 Done
    • Benjamin Kott +2
    • Benni Mack +2
    • Benjamin Franzke +1
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benjamin Kott +2
    • Benni Mack +2
    • Benjamin Franzke +1
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1621

  1. Benjamin Kott uploaded patch set 1 08/26/26, 23:46

  2. core-ci voted on patch set 1 V +1 08/26/26, 23:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107197

  3. Josua Vogel voted on patch set 1 CR +1 08/27/26, 08:10

  4. Benni Mack updated the commit message in patch set 2 CR +1 V +1 09/23/26, 15:45

  5. Benni Mack rebased onto patch set 3 09/23/26, 15:45

  6. core-ci voted on patch set 2 V +1 09/23/26, 16:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109078

  7. core-ci voted on patch set 3 V +1 09/23/26, 16:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109079

  8. Josua Vogel voted on patch set 3 CR +1 09/24/26, 07:05

  9. Andreas Kienast commented on patch set 3 10/10/26, 17:11

    I wonder whether we can solve this at a lower level instead, namely LanguageServiceFactory: ``` public function create(Locale|string $locale): LanguageService { if (is_string($locale) || $locale->getDependencies() === []) { $locale = $this->locales->createLocale((string)$locale); } $obj = new LanguageService($this->locales, $this->localizationFactory, $this->runtimeCache); $obj->init($locale); return $obj; } ``` Why there: - LocalizationUtility::translate() already calls create($locale), so it's covered with no change to LocalizationUtility itself. - Other callers that pass Locale objects have the same issue and get fixed too: EXT:form's TranslationService::createLanguageService(), PageRenderer, and any extension that does $languageServiceFactory->create($siteLanguage->getLocale()). - It does exactly what createFromSiteLanguage() already does by casting to string. That method could later be simplified to create($language->getLocale()).
  10. Benni Mack uploaded patch set 4 CR +1 V +1 10/15/26, 12:46

  11. Benni Mack commented on patch set 4 CR +1 V +1 10/15/26, 12:47

    Reply

    thanks, I agree, much better.
  12. core-ci voted on patch set 4 V +1 10/15/26, 12:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111190

  13. Benjamin Franzke commented on patch set 4 10/15/26, 15:13

    LanguageServiceFactory.php:35

    A question because this is a bit hard to understand: Shouldn't `SiteLanguage` create the locale via `Locales->createLocale()` instead of creating an – as it seems – incomplete object (by simply using `new Locale($locale))` right now)?
  14. Benni Mack commented on patch set 4 10/15/26, 16:05

    LanguageServiceFactory.php:35 Reply

    indeed, yes, but IMHO a separate issue. The main problem is that we do not have proper factories for Site + SiteLanguage right now. I stumbled over this multiple times, and I avoided this in SiteLanguages' constructor until now (to keep the objects clean from makeInstance),
  15. Benjamin Franzke uploaded patch set 5 CR +1 V +1 10/16/26, 11:45

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

  17. Benjamin Franzke commented on patch set 5 CR +1 V +1 10/16/26, 12:26

    LanguageServiceFactory.php:35 Reply

    Adapted as discussed in call, by avoiding to recreate a locale with zero dependencies.
  18. Garvin Hicking voted on patch set 5 CR +1 V +1 10/16/26, 12:57

  19. Benni Mack voted on patch set 5 CR +2 V +2 10/16/26, 13:19

  20. Benjamin Kott voted on patch set 5 CR +2 V +2 10/16/26, 14:14

  21. Benjamin Kott merged patch set 6 10/16/26, 14:14