This class is used to translate strings in plain PHP. For examples
see Localization in PHP. A
LanguageService should not
be created directly, therefore its constructor is internal. Create a
LanguageService with the LanguageServiceFactory.
In the backend context a
LanguageService is stored in the global
- class TYPO3\CMS\Core\Localization\LanguageService¶
Main API to fetch labels from XLF (label files) based on the current system language of TYPO3. It is able to resolve references to files + their pointers to the proper language. If you see something about "LLL", this class does the trick for you. It is not related for language handling of content, but rather of labels for plugins.
Usually this is injected into $GLOBALS['LANG'] when in backend or CLI context, and populated by the current backend user. Don't rely on $GLOBAL['LANG'] in frontend, as it is only available in certain circumstances! In Frontend, this is also used to translate "labels", see TypoScriptFrontendController->sL() for that.
As TYPO3 internally does not match the proper ISO locale standard, the "locale" here is actually a list of supported language keys, (see Locales class), whereas "english" has the language key "default".
- property lang¶
This is set to the language that is currently running for the user
- property debugKey¶
If TRUE, will show the key/location of labels in the backend.
- getLL(string $index)¶
Returns the label with key $index from the globally loaded $LOCAL_LANG array.
Mostly used from modules with only one LOCAL_LANG file loaded into the global space.
string) -- Label key
- sL(string $input)¶
Main and most often used method.
- Resolve strings like these:
This looks up the given .xlf file path in the 'core' extension for label 'labels.depth_0'
string) -- Label key/reference
- Return type
- includeLLFile(string $fileRef)¶
Includes locallang file (and possibly additional localized version if configured for) Read language labels will be merged with $LOCAL_LANG (if $setGlobal = TRUE).
string) -- $fileRef is a file-reference