TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Extbase\Utility\LocalizationUtility Class Reference

Static Public Member Functions

static translate ($key, $extensionName, $arguments=null)
 

Static Protected Member Functions

static translateFileReference ($key)
 
static loadTypoScriptLabels ($extensionName)
 
static flattenTypoScriptLabelArray (array $labelValues, $parentKey='')
 
static getConfigurationManager ()
 
static getTypoScriptFrontendController ()
 
static getLanguageService ()
 

Static Protected Attributes

static $locallangPath = 'Resources/Private/Language/'
 
static $LOCAL_LANG = []
 
static $LOCAL_LANG_UNSET = []
 
static $languageKey = 'default'
 
static $alternativeLanguageKeys = []
 
static $configurationManager = null
 

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 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$labelValuesHierarchical array of labels
string$parentKeythe name of the parent key in the recursion; is only needed for recursion.
Returns
array flattened array of labels.

Definition at line 253 of file LocalizationUtility.php.

◆ getConfigurationManager()

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

Returns instance of the configuration manager

Returns

Definition at line 275 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\$configurationManager, and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ getLanguageService()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::getLanguageService ( )
staticprotected
Returns

Definition at line 297 of file LocalizationUtility.php.

References $GLOBALS.

◆ getTypoScriptFrontendController()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::getTypoScriptFrontendController ( )
staticprotected
Returns

Definition at line 289 of file LocalizationUtility.php.

References $GLOBALS.

◆ loadTypoScriptLabels()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::loadTypoScriptLabels (   $extensionName)
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
Returns
void

Definition at line 211 of file LocalizationUtility.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\$configurationManager, TYPO3\CMS\Extbase\Utility\LocalizationUtility\$languageKey, and TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK.

◆ translate()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate (   $key,
  $extensionName,
  $arguments = null 
)
static

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

Parameters
string$keyThe key from the LOCAL_LANG array for which to return the value.
string$extensionNameThe name of the extension
array$argumentsthe arguments of the extension, being passed over to vsprintf
Returns
string|NULL The value from LOCAL_LANG or NULL if no translation was found.
Todo:
: If vsprintf gets a malformed string, it returns FALSE! Should we throw an exception there?

Definition at line 81 of file LocalizationUtility.php.

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

Referenced by TYPO3\CMS\Extensionmanager\Controller\ListController\addComposerModeNotification(), TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\clearLabelWithTypoScript(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileResultRows(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow(), TYPO3\CMS\Form\Controller\FrontendController\confirmationAction(), TYPO3\CMS\Belog\Controller\AbstractController\createPageDepthOptions(), TYPO3\CMS\Belog\Controller\AbstractController\createUserAndGroupListForSelectOptions(), TYPO3\CMS\Lang\Controller\LanguageController\deactivateLanguageAction(), TYPO3\CMS\Recycler\Controller\RecyclerAjaxController\dispatch(), TYPO3\CMS\Beuser\Controller\PermissionController\editAction(), TYPO3\CMS\Documentation\Controller\DocumentController\fetchAction(), 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\IndexedSearch\Controller\SearchController\getDisplayResults(), TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService\getInlineLabel(), TYPO3\CMS\Extbase\Scheduler\FieldProvider\getLanguageLabel(), TYPO3\CMS\Form\Domain\Validator\AlphabeticValidator\getLocalLanguageLabel(), TYPO3\CMS\Form\Domain\Validator\AlphanumericValidator\getLocalLanguageLabel(), TYPO3\CMS\Form\Domain\Validator\BetweenValidator\getLocalLanguageLabel(), TYPO3\CMS\Form\Domain\Validator\AbstractValidator\getLocalLanguageLabel(), TYPO3\CMS\Form\Domain\Validator\LengthValidator\getLocalLanguageLabel(), TYPO3\CMS\Form\PostProcess\MailPostProcessor\getLocalLanguageLabel(), TYPO3\CMS\Beuser\Controller\PermissionController\getRecursiveSelectOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getSearchWords(), TYPO3\CMS\Workspaces\ExtDirect\ExtDirectServer\getSystemLanguages(), TYPO3\CMS\Form\Domain\Validator\DateValidator\humanReadableDateFormat(), TYPO3\CMS\Beuser\Controller\PermissionController\initializeView(), TYPO3\CMS\Extensionmanager\ViewHelpers\UpdateScriptViewHelper\injectObjectManager(), TYPO3\CMS\Extensionmanager\Controller\DownloadController\installDistributionAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeDescription(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeRating(), TYPO3\CMS\Lowlevel\View\ConfigurationView\menuConfig(), TYPO3\CMS\Extensionmanager\Controller\ActionController\removeExtensionAction(), TYPO3\CMS\Extensionmanager\ViewHelpers\RemoveExtensionViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ShowExtensionVersionsViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ConfigureExtensionViewHelper\render(), TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\render(), TYPO3\CMS\Belog\ViewHelpers\HistoryEntryViewHelper\render(), TYPO3\CMS\Beuser\ViewHelpers\RemoveUserViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ReloadSqlDataViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\Be\PageRendererViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\DownloadExtensionViewHelper\render(), TYPO3\CMS\Beuser\ViewHelpers\SwitchUserViewHelper\renderStatic(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\renderStatic(), TYPO3\CMS\Beuser\ViewHelpers\PermissionsViewHelper\renderStatic(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\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\Extensionmanager\Domain\Repository\ConfigurationItemRepository\translate(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateForEmptyStringKeyReturnsNull(), TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateForEmptyStringKeyWithArgumentsReturnsNull(), TYPO3\CMS\Belog\ViewHelpers\Form\TranslateLabelSelectViewHelper\translateLabel(), and TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\translateTest().

◆ translateFileReference()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::translateFileReference (   $key)
staticprotected

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

Parameters
string$keyThe language key including the path to a custom locallang file ("LLL:path:key").
Returns
string The value from LOCAL_LANG or NULL if no translation was found.
See also
language::sL()
::sL()

Definition at line 129 of file LocalizationUtility.php.

References $GLOBALS, $locales, TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Member Data Documentation

◆ $alternativeLanguageKeys

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$alternativeLanguageKeys = []
staticprotected

Definition at line 64 of file LocalizationUtility.php.

◆ $configurationManager

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$configurationManager = null
staticprotected

◆ $languageKey

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$languageKey = 'default'
staticprotected

◆ $LOCAL_LANG

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$LOCAL_LANG = []
staticprotected

Definition at line 40 of file LocalizationUtility.php.

◆ $LOCAL_LANG_UNSET

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$LOCAL_LANG_UNSET = []
staticprotected

Definition at line 50 of file LocalizationUtility.php.

◆ $locallangPath

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

Definition at line 33 of file LocalizationUtility.php.