#111279Locales::createLocale() silently falls back to English for an unlisted locale
Description
Problem
A site language whose locale is not listed in TYPO3\CMS\Core\Localization\Locales::$languages resolves to English. There is no exception, no log entry and no hint in the backend.
Content translation keeps working, because that is driven by sys_language_uid. So the site renders its translated records next to English labels and nothing says why.
Example: a site language with the locale zu_ZA, a valid ISO 639-1 code the site configuration module offers, ends up as en in the LanguageService. A zu.locallang.xlf is never read.
Cause
Locales::createLocale() returns the default Locale when isValidLanguageKey() says no, and Locale::__construct() defaults to 'en':
if ($this->isValidLanguageKey($localeKey)) {
return new Locale($localeKey, $dependencies);
}
return new Locale();
Locales::setLocale() writes an error to the log when the system locale behind a site language is missing, which costs date and number formatting. createLocale() says nothing when it discards the locale altogether, which costs every label on the site.
The same fallback is in 13.4, 14.3 and main.
Suggested fix
Log a warning before returning the fallback. Which locale comes back does not change, so this is safe for the maintained release branches.
Reviews 1
History 02
-
Gerrit Code Review pushed patch set 1 for main to change 97215 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-29T17:43:16+00:00" > 10/29/26, 17:43 </span> -
Gerrit Code Review pushed patch set 2 for main to change 97215 <span data-processor="relativetime" data-value="2026-10-29T18:03:12+00:00" > 10/29/26, 18:03 </span>