TranslationService implements SingletonInterface

Advanced translations This class is subjected to change.

Do NOT subclass

Scope: frontend / backend

Internal

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$alternativeLanguageKeys  : array
Pointer to alternative fall-back language to use
$configurationManager  : ConfigurationManagerInterface
$languageKey  : string
Key of the language to use
$LOCAL_LANG  : array
Local Language content
$LOCAL_LANG_UNSET  : array
Contains those LL keys, which have been set to (empty) in TypoScript.

Methods

__construct()  : mixed
getInstance()  : self
Return TranslationService as singleton
getLanguage()  : string
setLanguage()  : mixed
translate()  : mixed
Returns the localized label of the LOCAL_LANG key, $key.
translateFinisherOption()  : string
translateFormElementError()  : string
translateFormElementValue()  : string|array
translateToAllBackendLanguages()  : array
translateValuesRecursive()  : array
Recursively translate values.
flattenTypoScriptLabelArray()  : array
Flatten TypoScript label array; converting a hierarchical array into a flat array with the keys separated by dots.
getAllTypo3BackendLanguages()  : array
getCurrentSiteLanguage()  : SiteLanguage|null
Returns the currently configured "site language" if a site is configured (= resolved) in the current request.
getLanguageService()  : LanguageService
initializeLocalization()  : mixed
loadTypoScriptLabels()  : mixed
Overwrites labels that are set via TypoScript.
processTranslationChain()  : string|null
setLanguageKeys()  : mixed
Sets the currently active language keys.
sortArrayWithIntegerKeysDescending()  : array
If the array contains numerical keys only, sort it in descending order

Properties

$alternativeLanguageKeys

Pointer to alternative fall-back language to use

protected array $alternativeLanguageKeys = []

$languageKey

Key of the language to use

protected string $languageKey

$LOCAL_LANG

Local Language content

protected array $LOCAL_LANG = []

$LOCAL_LANG_UNSET

Contains those LL keys, which have been set to (empty) in TypoScript.

protected array $LOCAL_LANG_UNSET = []

This is necessary, as we cannot distinguish between a nonexisting translation and a label that has been cleared by TS. In both cases ['key'][0]['target'] is "".

Methods

getInstance()

Return TranslationService as singleton

public static getInstance() : self
Deprecated

will be removed in TYPO3 v12.0. Use Dependency Injection or GeneralUtility::makeInstance() if DI is not possible.

Internal
Return values
self

getLanguage()

public getLanguage() : string
Internal
Return values
string

setLanguage()

public setLanguage(string $languageKey) : mixed
Parameters
$languageKey : string
Internal

translate()

Returns the localized label of the LOCAL_LANG key, $key.

public translate(mixed $key[, array $arguments = null ][, string $locallangPathAndFilename = null ][, string $language = null ][, mixed $defaultValue = '' ]) : mixed
Parameters
$key : mixed

The key from the LOCAL_LANG array for which to return the value.

$arguments : array = null

the arguments of the extension, being passed over to vsprintf

$locallangPathAndFilename : string = null
$language : string = null
$defaultValue : mixed = ''
Internal
Return values
mixed —

The value from LOCAL_LANG or $defaultValue if no translation was found.

translateFinisherOption()

public translateFinisherOption(FormRuntime $formRuntime, string $finisherIdentifier, string $optionKey, string $optionValue[, array $renderingOptions = [] ]) : string
Parameters
$formRuntime : FormRuntime
$finisherIdentifier : string
$optionKey : string
$optionValue : string
$renderingOptions : array = []
Tags
throws
InvalidArgumentException
Return values
string

translateToAllBackendLanguages()

public translateToAllBackendLanguages(string $key[, array $arguments = null ][, array $translationFiles = [] ]) : array
Parameters
$key : string
$arguments : array = null
$translationFiles : array = []
Internal
Return values
array —

the modified array

translateValuesRecursive()

Recursively translate values.

public translateValuesRecursive(array $array[, array $translationFiles = [] ]) : array
Parameters
$array : array
$translationFiles : array = []
Internal
Return values
array —

the modified array

flattenTypoScriptLabelArray()

Flatten TypoScript label array; converting a hierarchical array into a flat array with the keys separated by dots.

protected flattenTypoScriptLabelArray(array $labelValues[, string $parentKey = '' ]) : array

Example Input: array('k1' => array('subkey1' => 'val1')) Example Output: array('k1.subkey1' => 'val1')

Parameters
$labelValues : array

Hierarchical array of labels

$parentKey : string = ''

the name of the parent key in the recursion; is only needed for recursion.

Return values
array —

flattened array of labels.

getAllTypo3BackendLanguages()

protected getAllTypo3BackendLanguages() : array
Return values
array

getCurrentSiteLanguage()

Returns the currently configured "site language" if a site is configured (= resolved) in the current request.

protected getCurrentSiteLanguage() : SiteLanguage|null
Return values
SiteLanguage|null

initializeLocalization()

protected initializeLocalization(string $locallangPathAndFilename) : mixed
Parameters
$locallangPathAndFilename : string

loadTypoScriptLabels()

Overwrites labels that are set via TypoScript.

protected loadTypoScriptLabels() : mixed

TS locallang labels have to be configured like: plugin.tx_form._LOCAL_LANG.languageKey.key = value

processTranslationChain()

protected processTranslationChain(array $translationKeyChain[, string $language = null ][, array $arguments = null ]) : string|null
Parameters
$translationKeyChain : array
$language : string = null
$arguments : array = null
Return values
string|null

setLanguageKeys()

Sets the currently active language keys.

protected setLanguageKeys() : mixed

sortArrayWithIntegerKeysDescending()

If the array contains numerical keys only, sort it in descending order

protected sortArrayWithIntegerKeysDescending(array $array) : array
Parameters
$array : array
Return values
array
On this page

Search results