TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fixtures\TranslateViewHelperFixtureForEmptyString TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fixtures\TranslateViewHelperFixtureForTranslatedString

Public Member Functions

 render ($key=null, $id=null, $default=null, $htmlEscape=null, array $arguments=null, $extensionName=null)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 isEscapingInterceptorEnabled ()
 
 setViewHelperNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
 
 setRenderChildrenClosure (\Closure $renderChildrenClosure)
 
 initializeArgumentsAndRender ()
 
 initialize ()
 
 renderChildren ()
 
 prepareArguments ()
 
 validateArguments ()
 
 initializeArguments ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
 resetState ()
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 

Static Public Member Functions

static renderStatic (array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 

Static Protected Member Functions

static translate ($id, $extensionName, $arguments)
 

Additional Inherited Members

- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 registerArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 overrideArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 callRenderMethod ()
 
 getLogger ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = null
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = true
 

Detailed Description

Translate a key from locallang. The files are loaded from the folder "Resources/Private/Language/".

== Examples ==

<f:translate key="key1" /> <output> value of key "key1" in the current website language </output>

<f:translate key="htmlKey" htmlEscape="false" /> <output> value of key "htmlKey" in the current website language, no htmlspecialchars applied </output>

<f:translate key="LLL:EXT:myext/Resources/Private/Language/locallang.xlf:key1" /> <output> value of key "key1" in the current website language </output>

{f:translate(key: 'argumentsKey', arguments: {0: 'dog', 1: 'fox'}, default: 'default value')} <output> value of key "argumentsKey" in the current website language with "%1" and "%2" are replaced by "dog" and "fox" (printf) if the key is not found, the output is "default value" </output>

{f:translate(key: 'someKey', extensionName: 'SomeExtensionName')} <output> value of key "someKey" in the current website language the locallang file of extension "some_extension_name" will be used </output>

<f:translate id="key1" /> <output> value of id "key1" in the current website language </output>

Definition at line 74 of file TranslateViewHelper.php.

Member Function Documentation

◆ render()

TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper::render (   $key = null,
  $id = null,
  $default = null,
  $htmlEscape = null,
array  $arguments = null,
  $extensionName = null 
)

Render translation

Parameters
string$keyTranslation Key
string$idTranslation Key compatible to TYPO3 Flow
string$defaultIf the given locallang key could not be found, this value is used. If this argument is not set, child nodes will be used to render the default
bool$htmlEscapeTRUE if the result should be htmlescaped. This won't have an effect for the default value
array$argumentsArguments to be replaced in the resulting string
string$extensionNameUpperCamelCased extension key (for example BlogExample)
Returns
string The translated key or tag body if key doesn't exist

Definition at line 87 of file TranslateViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$arguments, and TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\buildRenderChildrenClosure().

◆ renderStatic()

static TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper::renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
RenderingContextInterface  $renderingContext 
)
static

Return array element by key.

Parameters
array$arguments
\Closure$renderChildrenClosure
RenderingContextInterface$renderingContext
Exceptions
InvalidVariableException
Returns
string

Definition at line 112 of file TranslateViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$renderChildrenClosure, and TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface\getControllerContext().

◆ translate()

static TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper::translate (   $id,
  $extensionName,
  $arguments 
)
staticprotected

Wrapper call to static LocalizationUtility

Parameters
string$idTranslation Key compatible to TYPO3 Flow
string$extensionNameUpperCamelCased extension key (for example BlogExample)
array$argumentsArguments to be replaced in the resulting string
Returns
NULL|string

Definition at line 153 of file TranslateViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$arguments, and TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate().