LanguageServiceFactory 

The \TYPO3\CMS\Core\Localization\LanguageServiceFactory class is for retrieving a TYPO3CMSCoreLocalizationTranslatorInterface instance at runtime, which is then used to translate strings in plain PHP.

For examples see Localization in PHP. Creates a Translator API that can then be used for localization.

class LanguageServiceFactory
Fully qualified name
\TYPO3\CMS\Core\Localization\LanguageServiceFactory
create(\TYPO3\CMS\Core\Localization\Locale|string $locale)

Factory method to create a language service object.

A Locale without resolved dependencies (e.g. one of a SiteLanguage) gets them resolved, so "de-AT" falls back to "de". An object with resolved dependencies is kept.

param $locale

the locale

Returns
\TYPO3\CMS\Core\Localization\LanguageService
createFromUserPreferences(?\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication $user)
param $user

the user

Returns
\TYPO3\CMS\Core\Localization\LanguageService
createFromSiteLanguage(\TYPO3\CMS\Core\Site\Entity\SiteLanguage $language)
param $language

the language

Returns
\TYPO3\CMS\Core\Localization\LanguageService