Attention

TYPO3 v9 has reached its end-of-life September 30th, 2021 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

You can order Extended Long Term Support (ELTS) here: TYPO3 ELTS.

translate

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

Examples

Translate key

<f:translate key="key1" />

Value of key key1 in the current website language. Alternatively id can be used instead of key:

<f:translate id="key1" />

This will output the same as above. If both id and key are set, id will take precedence.

Keep HTML tags

<f:format.raw><f:translate key="htmlKey" /></f:format.raw>

Value of key htmlKey in the current website language, no htmlspecialchars() applied.

Translate key from custom locallang file

<f:translate key="LLL:EXT:myext/Resources/Private/Language/locallang.xlf:key1" />

Value of key key1 in the current website language.

Inline notation with arguments and default value

{f:translate(key: 'someKey', arguments: {0: 'dog', 1: 'fox'}, default: 'default value')}

Value of key someKey in the current website language with the given arguments (dog and fox) assigned for the specified %s conversions (sprintf()) in the language file:

<trans-unit id="someKey" resname="someKey">
    <source>Some text about a %s and a %s.</source>
</trans-unit>

The output will be "Some text about a dog and a fox".

If the key someKey is not found in the language file, the output is default value.

Inline notation with extension name

{f:translate(key: 'someKey', extensionName: 'SomeExtensionName')}

Value of key someKey in the current website language. The locallang file of extension "some_extension_name" will be used.

Arguments

key

DataType

string

Required

false

Description

Translation Key

id

DataType

string

Required

false

Description

Translation ID. Same as key.

default

DataType

string

Required

false

Description

If 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

arguments

DataType

mixed

Required

false

Description

Arguments to be replaced in the resulting string

extensionName

DataType

string

Required

false

Description

UpperCamelCased extension key (for example BlogExample)

languageKey

DataType

string

Required

false

Description

Language key ("dk" for example) or "default" to use for this translation. If this argument is empty, we use the current language

alternativeLanguageKeys

DataType

mixed

Required

false

Description

Alternative language keys if no translation does exist