‪TYPO3CMS  11.5
TYPO3\CMS\Extbase\Utility\LocalizationUtility Class Reference

Static Public Member Functions

static string null translate (string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
 

Static Protected Member Functions

static initializeLocalization (string $languageFilePath, string $languageKey, array $alternativeLanguageKeys, string $extensionName=null)
 
static string getLanguageFilePath (string $extensionName)
 
static array getLanguageKeys ()
 
static loadTypoScriptLabels (string $extensionName, string $languageFilePath)
 
static array flattenTypoScriptLabelArray (array $labelValues, string $parentKey='')
 
static TYPO3 CMS Extbase Configuration ConfigurationManagerInterface getConfigurationManager ()
 
static SiteLanguage null getCurrentSiteLanguage ()
 
static TYPO3 CMS Core Localization LanguageService getLanguageService ()
 

Static Protected Attributes

static string $locallangPath = 'Resources/Private/Language/'
 
static array $LOCAL_LANG = array( )
 
static array $LOCAL_LANG_UNSET = array( )
 
static TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
 

Detailed Description

Localization helper which should be used to fetch localized labels.

Definition at line 32 of file LocalizationUtility.php.

Member Function Documentation

◆ flattenTypoScriptLabelArray()

static array TYPO3\CMS\Extbase\Utility\LocalizationUtility::flattenTypoScriptLabelArray ( array  $labelValues,
string  $parentKey = '' 
)
staticprotected

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 266 of file LocalizationUtility.php.

Referenced by TYPO3\CMS\Extbase\Utility\LocalizationUtility\loadTypoScriptLabels().

◆ getConfigurationManager()

static TYPO3 CMS Extbase Configuration ConfigurationManagerInterface TYPO3\CMS\Extbase\Utility\LocalizationUtility::getConfigurationManager ( )
staticprotected

Returns instance of the configuration manager

Returns
‪\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface

Definition at line 292 of file LocalizationUtility.php.

◆ getCurrentSiteLanguage()

static SiteLanguage null TYPO3\CMS\Extbase\Utility\LocalizationUtility::getCurrentSiteLanguage ( )
staticprotected

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

Returns
‪SiteLanguage|null

Definition at line 307 of file LocalizationUtility.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Extbase\Utility\LocalizationUtility\getLanguageKeys().

◆ getLanguageFilePath()

static string TYPO3\CMS\Extbase\Utility\LocalizationUtility::getLanguageFilePath ( string  $extensionName)
staticprotected

Returns the default path and filename for an extension

Parameters
string$extensionName
Returns
‪string

Definition at line 175 of file LocalizationUtility.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored().

◆ getLanguageKeys()

static array TYPO3\CMS\Extbase\Utility\LocalizationUtility::getLanguageKeys ( )
staticprotected

Sets the currently active language keys.

Returns
‪array

Definition at line 185 of file LocalizationUtility.php.

References $GLOBALS, TYPO3\CMS\Core\Http\ApplicationType\fromRequest(), and TYPO3\CMS\Extbase\Utility\LocalizationUtility\getCurrentSiteLanguage().

◆ getLanguageService()

static TYPO3 CMS Core Localization LanguageService TYPO3\CMS\Extbase\Utility\LocalizationUtility::getLanguageService ( )
staticprotected
Returns
‪\TYPO3\CMS\Core\Localization\LanguageService

Definition at line 318 of file LocalizationUtility.php.

References $GLOBALS.

◆ initializeLocalization()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::initializeLocalization ( string  $languageFilePath,
string  $languageKey,
array  $alternativeLanguageKeys,
string  $extensionName = null 
)
staticprotected

Loads local-language values by looking for a "locallang.xlf" file in the plugin resources directory and if found includes it. Also locallang values set in the TypoScript property "_LOCAL_LANG" are merged onto the values found in the "locallang.xlf" file.

Parameters
string$languageFilePath
string$languageKey
string[]$alternativeLanguageKeys
string$extensionName

Definition at line 142 of file LocalizationUtility.php.

◆ loadTypoScriptLabels()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::loadTypoScriptLabels ( string  $extensionName,
string  $languageFilePath 
)
staticprotected

Overwrites labels that are set via TypoScript. TS locallang labels have to be configured like: plugin.tx_myextension._LOCAL_LANG.languageKey.key = value

Parameters
string$extensionName
string$languageFilePath

Definition at line 224 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\$configurationManager, TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK, TYPO3\CMS\Extbase\Utility\LocalizationUtility\flattenTypoScriptLabelArray(), and TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\getConfiguration().

◆ translate()

static string null TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate ( string  $key,
?string  $extensionName = null,
array  $arguments = null,
string  $languageKey = null,
array  $alternativeLanguageKeys = null 
)
static

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

Parameters
string$key‪The key from the LOCAL_LANG array for which to return the value.
string | null$extensionName‪The name of the extension
array$arguments‪The arguments of the extension, being passed over to sprintf
string$languageKey‪The language key or null for using the current language from the system
string[]$alternativeLanguageKeys‪The alternative language keys if no translation was found.
Returns
‪string|null The value from LOCAL_LANG or null if no translation was found.

Definition at line 67 of file LocalizationUtility.php.

Referenced by TYPO3\CMS\Extensionmanager\Controller\ListController\addComposerModeNotification(), TYPO3\CMS\Beuser\Controller\BackendUserController\addMainMenu(), TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\clearLabelWithTypoScript(), TYPO3\CMS\Beuser\Controller\BackendUserController\compareAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\compareGroupsAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileResultRows(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow(), TYPO3\CMS\Belog\Controller\BackendLogController\createPageDepthOptions(), TYPO3\CMS\Belog\Controller\BackendLogController\createUserAndGroupListForSelectOptions(), TYPO3\CMS\Belog\Controller\BackendLogController\createWorkspaceListForSelectOptions(), TYPO3\CMS\Belog\Controller\BackendLogController\deleteMessageAction(), TYPO3\CMS\Recycler\Controller\RecyclerAjaxController\dispatch(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableGroupOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableIndexConfigurationsOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableLanguageOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableMediaTypesOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableOperandsOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSearchTypeOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSectionsOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSortDescendingOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSortOrderOptions(), TYPO3\CMS\Recycler\Controller\RecyclerAjaxController\getBackendUserInformation(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getDisplayResults(), TYPO3\CMS\FrontendLogin\Service\RecoveryService\getEmailSubject(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getSearchWords(), TYPO3\CMS\FrontendLogin\Controller\PasswordRecoveryController\getTranslation(), TYPO3\CMS\Beuser\Controller\BackendUserController\groupsAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\indexAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\initializeAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\initiatePasswordResetAction(), TYPO3\CMS\Extensionmanager\Controller\DownloadController\installDistributionAction(), TYPO3\CMS\Belog\Controller\BackendLogController\listAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeDescription(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeRating(), TYPO3\CMS\Beuser\Controller\BackendUserController\onlineAction(), TYPO3\CMS\Extensionmanager\Controller\ActionController\removeExtensionAction(), TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ReloadSqlDataViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ToggleExtensionInstallationStateViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\DownloadExtensionViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\renderStatic(), TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\renderStatic(), TYPO3\CMS\Beuser\ViewHelpers\SwitchUserViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Be\PageRendererViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper\renderStatic(), TYPO3\CMS\Beuser\ViewHelpers\PermissionsViewHelper\resolvePermissionLabel(), TYPO3\CMS\IndexedSearch\Controller\SearchController\searchAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\showAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\terminateBackendUserSessionAction(), TYPO3\CMS\Extensionmanager\Controller\AbstractController\translate(), TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper\translate(), TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\translateErrorMessage(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateForEmptyStringKeyReturnsNull(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateForEmptyStringKeyWithArgumentsReturnsNull(), TYPO3\CMS\Belog\ViewHelpers\Form\TranslateLabelSelectViewHelper\translateLabel(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateTestWithBackendUserLanguage(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateTestWithExplicitLanguageParameters(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateThrowsExceptionWithEmptyExtensionNameIfKeyIsNotPrefixedWithLLL(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateWillReturnLabelsFromTsEvenIfNoXlfFileExists(), and TYPO3\CMS\Extensionmanager\Utility\InstallUtility\uninstall().

Member Data Documentation

◆ $configurationManager

TYPO3 CMS Extbase Configuration ConfigurationManagerInterface TYPO3\CMS\Extbase\Utility\LocalizationUtility::$configurationManager
staticprotected

◆ $LOCAL_LANG

array TYPO3\CMS\Extbase\Utility\LocalizationUtility::$LOCAL_LANG = array( )
staticprotected

Local Language content

Definition at line 42 of file LocalizationUtility.php.

◆ $LOCAL_LANG_UNSET

array TYPO3\CMS\Extbase\Utility\LocalizationUtility::$LOCAL_LANG_UNSET = array( )
staticprotected

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 51 of file LocalizationUtility.php.

◆ $locallangPath

string TYPO3\CMS\Extbase\Utility\LocalizationUtility::$locallangPath = 'Resources/Private/Language/'
staticprotected

Definition at line 36 of file LocalizationUtility.php.