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

Static Public Member Functions

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

Static Protected Member Functions

static initializeLocalization (string $languageFilePath, Locale $locale, ?string $extensionName)
 
static buildLanguageService (Locale $locale, string $languageFilePath)
 
static getLanguageFilePath (string $extensionName)
 
static getLocale (Locale|string|null $localeOrLanguageKey)
 
static loadTypoScriptLabels (string $extensionName)
 
static array flattenTypoScriptLabelArray (array $labelValues, string $parentKey='')
 
static getRuntimeCache ()
 

Static Protected Attributes

static string $locallangPath = 'Resources/Private/Language/'
 

Detailed Description

Localization helper which should be used to fetch localized labels.

Definition at line 34 of file LocalizationUtility.php.

Member Function Documentation

◆ buildLanguageService()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::buildLanguageService ( Locale  $locale,
string  $languageFilePath 
)
staticprotected

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

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

◆ getLanguageFilePath()

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

Returns the default path and filename for an extension

Definition at line 123 of file LocalizationUtility.php.

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

◆ getLocale()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::getLocale ( Locale|string|null  $localeOrLanguageKey)
staticprotected

Resolves the currently active locale. Using the Locales factory, as it handles dependencies (e.g. "de-AT" falls back to "de").

Definition at line 132 of file LocalizationUtility.php.

References $GLOBALS.

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

◆ getRuntimeCache()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::getRuntimeCache ( )
staticprotected

◆ initializeLocalization()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::initializeLocalization ( string  $languageFilePath,
Locale  $locale,
?string  $extensionName 
)
staticprotected

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

Definition at line 96 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\buildLanguageService().

◆ loadTypoScriptLabels()

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

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

Definition at line 149 of file LocalizationUtility.php.

References $GLOBALS, TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK, TYPO3\CMS\Extbase\Utility\LocalizationUtility\flattenTypoScriptLabelArray(), and TYPO3\CMS\Core\Http\fromRequest.

◆ translate()

static string null TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate ( string  $key,
?string  $extensionName = null,
array  $arguments = null,
Locale|string  $languageKey = 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 | null$arguments‪The arguments of the extension, being passed over to sprintf
Locale | string | null$languageKey‪The language key or null for using the current language from the system
Returns
‪string|null The value from LOCAL_LANG or null if no translation was found.

Definition at line 47 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\getLocale().

Referenced by TYPO3\CMS\Extensionmanager\Controller\ListController\addComposerModeNotification(), TYPO3\CMS\Beuser\Controller\BackendUserController\addMainMenu(), TYPO3\CMS\Extbase\Tests\Functional\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\createSelectableNumberOfLogEntriesOptions(), 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\Redirects\Command\CheckIntegrityCommand\execute(), TYPO3\CMS\Beuser\Controller\BackendUserController\filemountsAction(), 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\Belog\Controller\BackendLogController\listAction(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\loadTypoScriptLabels(), 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\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Be\PageRendererViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper\renderStatic(), TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper\renderStatic(), 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\Extbase\Validation\Validator\AbstractValidator\translateErrorMessage(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateForEmptyStringKeyReturnsNull(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateForEmptyStringKeyWithArgumentsReturnsNull(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateTestWithBackendUserLanguage(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateTestWithExplicitLanguageParameters(), TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateThrowsExceptionWithEmptyExtensionNameIfKeyIsNotPrefixedWithLLL(), and TYPO3\CMS\Extbase\Tests\Functional\Utility\LocalizationUtilityTest\translateWillReturnLabelsFromTsEvenIfNoXlfFileExists().

Member Data Documentation

◆ $locallangPath

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

Definition at line 36 of file LocalizationUtility.php.