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

Static Public Member Functions

static string null translate ($key, $extensionName=null, $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 ($extensionName, $languageFilePath)
 
static array flattenTypoScriptLabelArray (array $labelValues, $parentKey='')
 
static TYPO3 CMS Extbase Configuration ConfigurationManagerInterface getConfigurationManager ()
 
static SiteLanguage null getCurrentSiteLanguage ()
 
static TYPO3 CMS Frontend Controller TypoScriptFrontendController getTypoScriptFrontendController ()
 
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 28 of file LocalizationUtility.php.

Member Function Documentation

◆ flattenTypoScriptLabelArray()

static array TYPO3\CMS\Extbase\Utility\LocalizationUtility::flattenTypoScriptLabelArray ( array  $labelValues,
  $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 268 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 294 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\$configurationManager.

◆ 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 311 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 171 of file LocalizationUtility.php.

◆ getLanguageKeys()

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

Sets the currently active language/language_alt keys. Default values are "default" for language key and an empty array for language_alt key.

Returns
‪array

Definition at line 182 of file LocalizationUtility.php.

References $GLOBALS, $locales, 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 330 of file LocalizationUtility.php.

References $GLOBALS.

◆ getTypoScriptFrontendController()

static TYPO3 CMS Frontend Controller TypoScriptFrontendController TYPO3\CMS\Extbase\Utility\LocalizationUtility::getTypoScriptFrontendController ( )
staticprotected
Returns
‪\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController

Definition at line 322 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" (or "locallang.xml") 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 138 of file LocalizationUtility.php.

◆ loadTypoScriptLabels()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::loadTypoScriptLabels (   $extensionName,
  $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 226 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 (   $key,
  $extensionName = null,
  $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 vsprintf
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. If null and we are in the frontend, then the language_alt from TypoScript setup will be used
Returns
‪string|null The value from LOCAL_LANG or null if no translation was found.

Definition at line 63 of file LocalizationUtility.php.

Referenced by TYPO3\CMS\Extensionmanager\Controller\ListController\addComposerModeNotification(), TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage(), TYPO3\CMS\Workspaces\Service\IntegrityService\checkLocalization(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\clearLabelWithTypoScript(), 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\Beuser\Controller\PermissionController\editAction(), 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\DeletedRecordsController\getBackendUser(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getDisplayResults(), TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService\getInlineLabel(), TYPO3\CMS\Extbase\Scheduler\FieldProvider\getLanguageLabel(), TYPO3\CMS\Beuser\Controller\PermissionController\getRecursiveSelectOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getSearchWords(), TYPO3\CMS\Workspaces\Controller\Remote\RemoteServer\getSystemLanguages(), TYPO3\CMS\Beuser\Controller\PermissionController\indexAction(), TYPO3\CMS\Extensionmanager\Controller\DownloadController\installDistributionAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeDescription(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeRating(), TYPO3\CMS\Extensionmanager\Controller\ActionController\removeExtensionAction(), TYPO3\CMS\Extensionmanager\ViewHelpers\ShowExtensionVersionsViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ReloadSqlDataViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ToggleExtensionInstallationStateViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\DownloadExtensionViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\renderStatic(), TYPO3\CMS\Beuser\ViewHelpers\SwitchUserViewHelper\renderStatic(), TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\renderStatic(), TYPO3\CMS\Beuser\ViewHelpers\PermissionsViewHelper\renderStatic(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Be\PageRendererViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper\renderStatic(), TYPO3\CMS\IndexedSearch\Controller\SearchController\searchAction(), TYPO3\CMS\Filelist\Controller\FileListController\searchAction(), TYPO3\CMS\Beuser\Controller\BackendUserController\terminateBackendUserSessionAction(), TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper\translate(), 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(), and TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateWillReturnLabelsFromTsEvenIfNoXlfFileExists().

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

◆ $locallangPath

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

Definition at line 32 of file LocalizationUtility.php.