‪TYPO3CMS  10.4
TYPO3\CMS\Form\Service\TranslationService Class Reference
Inheritance diagram for TYPO3\CMS\Form\Service\TranslationService:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

mixed translate ( $key, array $arguments=null, string $locallangPathAndFilename=null, string $language=null, $defaultValue='')
 
array translateValuesRecursive (array $array, array $translationFiles=[])
 
array translateToAllBackendLanguages (string $key, array $arguments=null, array $translationFiles=[])
 
string translateFinisherOption (FormRuntime $formRuntime, string $finisherIdentifier, string $optionKey, string $optionValue, array $renderingOptions=[])
 
string array translateFormElementValue (RootRenderableInterface $element, array $propertyParts, FormRuntime $formRuntime)
 
string translateFormElementError (RootRenderableInterface $element, int $code, array $arguments, string $defaultValue='', FormRuntime $formRuntime)
 
 setLanguage (string $languageKey)
 
string getLanguage ()
 

Static Public Member Functions

static TranslationService getInstance ()
 

Protected Member Functions

string null processTranslationChain (array $translationKeyChain, string $language=null, array $arguments=null)
 
 initializeLocalization (string $locallangPathAndFilename)
 
 setLanguageKeys ()
 
 loadTypoScriptLabels ()
 
array flattenTypoScriptLabelArray (array $labelValues, string $parentKey='')
 
array sortArrayWithIntegerKeysDescending (array $array)
 
ConfigurationManagerInterface getConfigurationManager ()
 
SiteLanguage null getCurrentSiteLanguage ()
 
array getAllTypo3BackendLanguages ()
 
LanguageService getLanguageService ()
 

Protected Attributes

array $LOCAL_LANG = array( )
 
array $LOCAL_LANG_UNSET = array( )
 
string $languageKey
 
array $alternativeLanguageKeys = array( )
 
TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
 

Detailed Description

Advanced translations This class is subjected to change. Do NOT subclass

Scope: frontend / backend

Definition at line 43 of file TranslationService.php.

Member Function Documentation

◆ flattenTypoScriptLabelArray()

array TYPO3\CMS\Form\Service\TranslationService::flattenTypoScriptLabelArray ( array  $labelValues,
string  $parentKey = '' 
)
protected

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

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

Parameters
array$labelValues‪Hierarchical array of labels
string$parentKey‪the name of the parent key in the recursion; is only needed for recursion.
Returns
‪array flattened array of labels.

Definition at line 652 of file TranslationService.php.

Referenced by TYPO3\CMS\Form\Service\TranslationService\loadTypoScriptLabels().

◆ getAllTypo3BackendLanguages()

array TYPO3\CMS\Form\Service\TranslationService::getAllTypo3BackendLanguages ( )
protected
Returns
‪array

Definition at line 715 of file TranslationService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Form\Service\TranslationService\translateToAllBackendLanguages().

◆ getConfigurationManager()

ConfigurationManagerInterface TYPO3\CMS\Form\Service\TranslationService::getConfigurationManager ( )
protected

Returns instance of the configuration manager

Returns
‪ConfigurationManagerInterface

Definition at line 688 of file TranslationService.php.

References TYPO3\CMS\Form\Service\TranslationService\$configurationManager.

Referenced by TYPO3\CMS\Form\Service\TranslationService\loadTypoScriptLabels().

◆ getCurrentSiteLanguage()

SiteLanguage null TYPO3\CMS\Form\Service\TranslationService::getCurrentSiteLanguage ( )
protected

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

Returns
‪SiteLanguage|null

Definition at line 704 of file TranslationService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Form\Service\TranslationService\setLanguageKeys().

◆ getInstance()

◆ getLanguage()

string TYPO3\CMS\Form\Service\TranslationService::getLanguage ( )
Returns
‪string

Definition at line 527 of file TranslationService.php.

References TYPO3\CMS\Form\Service\TranslationService\$languageKey.

◆ getLanguageService()

LanguageService TYPO3\CMS\Form\Service\TranslationService::getLanguageService ( )
protected
Returns
‪LanguageService

Definition at line 728 of file TranslationService.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Form\Service\TranslationService\setLanguageKeys().

◆ initializeLocalization()

TYPO3\CMS\Form\Service\TranslationService::initializeLocalization ( string  $locallangPathAndFilename)
protected

◆ loadTypoScriptLabels()

◆ processTranslationChain()

string null TYPO3\CMS\Form\Service\TranslationService::processTranslationChain ( array  $translationKeyChain,
string  $language = null,
array  $arguments = null 
)
protected

◆ setLanguage()

TYPO3\CMS\Form\Service\TranslationService::setLanguage ( string  $languageKey)
Parameters
string$languageKey

Definition at line 518 of file TranslationService.php.

References TYPO3\CMS\Form\Service\TranslationService\$languageKey.

◆ setLanguageKeys()

◆ sortArrayWithIntegerKeysDescending()

array TYPO3\CMS\Form\Service\TranslationService::sortArrayWithIntegerKeysDescending ( array  $array)
protected

◆ translate()

mixed TYPO3\CMS\Form\Service\TranslationService::translate (   $key,
array  $arguments = null,
string  $locallangPathAndFilename = null,
string  $language = null,
  $defaultValue = '' 
)

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

Parameters
mixed$key‪The key from the LOCAL_LANG array for which to return the value.
array$arguments‪the arguments of the extension, being passed over to vsprintf
string$locallangPathAndFilename
string$language
mixed$defaultValue
Returns
‪mixed The value from LOCAL_LANG or $defaultValue if no translation was found.

Definition at line 99 of file TranslationService.php.

References TYPO3\CMS\Form\Service\TranslationService\$languageKey, and TYPO3\CMS\Form\Service\TranslationService\initializeLocalization().

Referenced by TYPO3\CMS\Form\Mvc\Property\TypeConverter\UploadedFileReferenceConverter\getUploadErrorMessage(), TYPO3\CMS\Form\Service\TranslationService\processTranslationChain(), TYPO3\CMS\Form\Service\TranslationService\translateToAllBackendLanguages(), and TYPO3\CMS\Form\Service\TranslationService\translateValuesRecursive().

◆ translateFinisherOption()

string TYPO3\CMS\Form\Service\TranslationService::translateFinisherOption ( FormRuntime  $formRuntime,
string  $finisherIdentifier,
string  $optionKey,
string  $optionValue,
array  $renderingOptions = [] 
)

◆ translateFormElementError()

string TYPO3\CMS\Form\Service\TranslationService::translateFormElementError ( RootRenderableInterface  $element,
int  $code,
array  $arguments,
string  $defaultValue = '',
FormRuntime  $formRuntime 
)

◆ translateFormElementValue()

◆ translateToAllBackendLanguages()

array TYPO3\CMS\Form\Service\TranslationService::translateToAllBackendLanguages ( string  $key,
array  $arguments = null,
array  $translationFiles = [] 
)

◆ translateValuesRecursive()

Member Data Documentation

◆ $alternativeLanguageKeys

array TYPO3\CMS\Form\Service\TranslationService::$alternativeLanguageKeys = array( )
protected

Pointer to alternative fall-back language to use

Definition at line 71 of file TranslationService.php.

◆ $configurationManager

TYPO3 CMS Extbase Configuration ConfigurationManagerInterface TYPO3\CMS\Form\Service\TranslationService::$configurationManager
protected

◆ $languageKey

◆ $LOCAL_LANG

array TYPO3\CMS\Form\Service\TranslationService::$LOCAL_LANG = array( )
protected

Local Language content

Definition at line 50 of file TranslationService.php.

◆ $LOCAL_LANG_UNSET

array TYPO3\CMS\Form\Service\TranslationService::$LOCAL_LANG_UNSET = array( )
protected

Contains those LL keys, which have been set to (empty) in TypoScript. 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 "".

Definition at line 59 of file TranslationService.php.