TranslateViewHelper extends AbstractViewHelper

ViewHelper

This class is the implementation of a Fluid ViewHelper.

View this class in the TYPO3 ViewHelper reference: <f:translate>

FinalYes

ViewHelper to provide a translation for language keys ("locallang"/"LLL").

By default, the files are loaded from the folder Resources/Private/Language/.

Supports two placeholder formats:

  1. ICU MessageFormat with named arguments (for labels like "{count, plural, one {# file} other {# files}}"):

    <f:translate key="file_count" arguments="{count: fileCount}" />
    
  2. sprintf-style with positional arguments (for labels like "Downloaded %d times from %s"):

    <f:translate key="someKey" arguments="{0: 42, 1: 'server'}" />
    

Example usage:

  <f:translate key="LLL:EXT:myext/Resources/Private/Language/locallang.xlf:key1" />
  <f:translate key="items_count" arguments="{count: items.count}" />
  <f:translate key="someKey" arguments="{0: 'dog', 1: 'fox'}" />
Tags
see
https://php.net/sprintf
see
https://unicode-org.github.io/icu/userguide/format_parse/messages/
see
https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-translate

Table of Contents

Properties

$escapeChildren  : bool
Output is escaped already. We must not escape children, to avoid double encoding.

Methods

initializeArguments()  : void
render()  : string
Return array element by key.

Properties

$escapeChildren

Output is escaped already. We must not escape children, to avoid double encoding.

protected bool $escapeChildren = false

Methods

initializeArguments()

public initializeArguments() : void

render()

Return array element by key.

public render() : string
Return values
string

        
On this page

Search results