TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
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

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

static getConfigurationManager ( )
staticprotected

Returns instance of the configuration manager

Returns

Definition at line 274 of file LocalizationUtility.php.

References LocalizationUtility\$configurationManager, and GeneralUtility\makeInstance().

static getLanguageService ( )
staticprotected
Returns

Definition at line 296 of file LocalizationUtility.php.

References $GLOBALS.

static getTypoScriptFrontendController ( )
staticprotected
Returns

Definition at line 288 of file LocalizationUtility.php.

References $GLOBALS.

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

References LocalizationUtility\$configurationManager, LocalizationUtility\$languageKey, and ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK.

static 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 GeneralUtility\isFirstPartOfStr().

Referenced by ListController\addComposerModeNotification(), SystemInformationController\appendMessage(), LocalizationUtilityTest\clearLabelWithTypoScript(), SearchController\compileResultRows(), SearchController\compileSingleResultRow(), AbstractController\createPageDepthOptions(), AbstractController\createUserAndGroupListForSelectOptions(), RecyclerAjaxController\dispatch(), PermissionController\editAction(), DocumentController\fetchAction(), SearchController\getAllAvailableGroupOptions(), SearchController\getAllAvailableIndexConfigurationsOptions(), SearchController\getAllAvailableLanguageOptions(), SearchController\getAllAvailableMediaTypesOptions(), SearchController\getAllAvailableOperandsOptions(), SearchController\getAllAvailableSearchTypeOptions(), SearchController\getAllAvailableSectionsOptions(), SearchController\getAllAvailableSortDescendingOptions(), SearchController\getAllAvailableSortOrderOptions(), SearchController\getDisplayResults(), UserFileInlineLabelService\getInlineLabel(), FieldProvider\getLanguageLabel(), PermissionController\getRecursiveSelectOptions(), SearchController\getSearchWords(), RemoteServer\getSystemLanguages(), DownloadController\installDistributionAction(), SearchController\makeDescription(), SearchController\makeRating(), ConfigurationView\menuConfig(), ActionController\removeExtensionAction(), RemoveExtensionViewHelper\render(), ConfigureExtensionViewHelper\render(), PageRendererViewHelper\render(), ContainerViewHelper\render(), PageBrowsingResultsViewHelper\renderStatic(), SwitchUserViewHelper\renderStatic(), PermissionsViewHelper\renderStatic(), PageBrowsingViewHelper\renderStatic(), BytesViewHelper\renderStatic(), SearchController\searchAction(), FileListController\searchAction(), BackendUserController\terminateBackendUserSessionAction(), TranslateViewHelper\translate(), ConfigurationItemRepository\translate(), LocalizationUtilityTest\translateForEmptyStringKeyReturnsNull(), LocalizationUtilityTest\translateForEmptyStringKeyWithArgumentsReturnsNull(), TranslateLabelSelectViewHelper\translateLabel(), and LocalizationUtilityTest\translateTest().

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

Member Data Documentation

$alternativeLanguageKeys = []
staticprotected

Definition at line 64 of file LocalizationUtility.php.

$configurationManager = null
staticprotected
$languageKey = 'default'
staticprotected

Definition at line 57 of file LocalizationUtility.php.

Referenced by LocalizationUtility\loadTypoScriptLabels().

$LOCAL_LANG = []
staticprotected

Definition at line 40 of file LocalizationUtility.php.

$LOCAL_LANG_UNSET = []
staticprotected

Definition at line 50 of file LocalizationUtility.php.

$locallangPath = 'Resources/Private/Language/'
staticprotected

Definition at line 33 of file LocalizationUtility.php.