locales, $this->localizationFactory, $this->runtimeCache); $obj->init($locale instanceof Locale ? $locale : $this->locales->createLocale($locale)); return $obj; } public function createFromUserPreferences(?AbstractUserAuthentication $user): LanguageService { return $this->create($this->locales->createLocaleFromUserPreferences($user)); } public function createFromSiteLanguage(SiteLanguage $language): LanguageService { // createLocale from a string takes care of resolving the automatic dependencies of e.g. "de_AT" to also check for "de" // and also validates if TYPO3 supports the original language (at least in TYPO3 v12, there is a fixed list of // allowed language keys) return $this->create((string)$language->getLocale()); } /** * Creates a LanguageService based on the current backend user's preferences. * * @internal don't use this in your own code, as we implicitly have a global dependency here. */ public function createForBackendUser(): LanguageService { return $this->createFromUserPreferences($GLOBALS['BE_USER'] ?? null); } }