TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Extbase\Utility\LocalizationUtility Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Utility\LocalizationUtility:
Tx_Extbase_Utility_Localization

Static Public Member Functions

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

Static Protected Member Functions

static translateFileReference ($key)
 
static initializeLocalization ($extensionName)
 
static loadTypoScriptLabels ($extensionName)
 
static flattenTypoScriptLabelArray (array $labelValues, $parentKey='')
 
static convertCharset ($value, $charset)
 
static getConfigurationManager ()
 

Static Protected Attributes

static $locallangPath = 'Resources/Private/Language/'
 
static $LOCAL_LANG = array()
 
static $LOCAL_LANG_UNSET = array()
 
static $LOCAL_LANG_charset = array()
 
static $languageKey = 'default'
 
static $alternativeLanguageKeys = array()
 
static $configurationManager = NULL
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Localization helper which should be used to fetch localized labels.

Definition at line 21 of file LocalizationUtility.php.

Member Function Documentation

◆ convertCharset()

static TYPO3\CMS\Extbase\Utility\LocalizationUtility::convertCharset (   $value,
  $charset 
)
staticprotected

Converts a string from the specified character set to the current. The current charset is defined by the TYPO3 mode.

Parameters
string$valuestring to be converted
string$charsetThe source charset
Returns
string converted string

Definition at line 277 of file LocalizationUtility.php.

References $GLOBALS, and TYPO3_MODE.

◆ 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.

References $result.

◆ getConfigurationManager()

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

Returns instance of the configuration manager

Returns

Definition at line 291 of file LocalizationUtility.php.

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

◆ initializeLocalization()

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

Loads local-language values by looking for a "locallang.php" (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.php" file.

Parameters
string$extensionName
Returns
void

Definition at line 153 of file LocalizationUtility.php.

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

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

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\$configurationManager, $GLOBALS, TYPO3\CMS\Extbase\Utility\LocalizationUtility\$languageKey, and $LOCAL_LANG.

◆ 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 $LOCAL_LANG.

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Utility\LocalizationUtilityTest\clearLabelWithTypoScript(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileResultRows(), TYPO3\CMS\IndexedSearch\Controller\SearchController\compileSingleResultRow(), TYPO3\CMS\Belog\Controller\AbstractController\createUserAndGroupListForSelectOptions(), TYPO3\CMS\Documentation\Controller\DocumentController\fetchAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableMediaTypesOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSearchTypeOptions(), TYPO3\CMS\IndexedSearch\Controller\SearchController\getAllAvailableSectionsOptions(), 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\Extensionmanager\Controller\DownloadController\installDistributionAction(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeDescription(), TYPO3\CMS\IndexedSearch\Controller\SearchController\makeRating(), TYPO3\CMS\Beuser\ViewHelpers\SwitchUserViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingResultsViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\DownloadExtensionViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ShowExtensionVersionsViewHelper\render(), TYPO3\CMS\Extensionmanager\ViewHelpers\ConfigureExtensionViewHelper\render(), TYPO3\CMS\IndexedSearch\ViewHelpers\PageBrowsingViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\Be\ContainerViewHelper\render(), TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper\renderTranslation(), TYPO3\CMS\IndexedSearch\Controller\SearchController\searchAction(), 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 134 of file LocalizationUtility.php.

References $GLOBALS, and TYPO3_MODE.

Member Data Documentation

◆ $alternativeLanguageKeys

TYPO3\CMS\Extbase\Utility\LocalizationUtility::$alternativeLanguageKeys = array()
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 = array()
staticprotected

Definition at line 33 of file LocalizationUtility.php.

◆ $LOCAL_LANG_charset

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

Definition at line 50 of file LocalizationUtility.php.

◆ $LOCAL_LANG_UNSET

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

Definition at line 43 of file LocalizationUtility.php.

◆ $locallangPath

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

Definition at line 26 of file LocalizationUtility.php.