---
title: "Translate ViewHelper <f:translate>"
manual: "Fluid ViewHelper Reference"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-translate@main"
source: "Global/Translate.rst"
rendered: "2026-09-29T15:44:59+00:00"
---

# Translate ViewHelper `<f:translate>` {#typo3-fluid-translate}

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:

Example usage:

Go to the source code of this ViewHelper: [TranslateViewHelper.php (GitHub)](https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid/Classes/ViewHelpers/TranslateViewHelper.php).

> [!NOTE]
> **See also**
>
> -   [Working with XLIFF files](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/LocalizationApi/Index.html#xliff-api)
> -   [Multi-language Fluid templates](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/HowTo/Localization/Fluid.html#extension-localization-fluid)
> -   [Label references / Translation domains](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/Labels/Index.html#label-reference)
> -   [Feature: #107759 - TranslateViewHelper supports Translation Domain syntax](https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.0/Feature-107759-TranslateViewHelperSupportsTranslationDomainSyntax.html#feature-107759-1729433323)

**Table of contents**

-   [Using translation domains](https://docs.typo3.org/permalink/t3viewhelper:using-translation-domains@main)
-   [Backward compatible syntax](https://docs.typo3.org/permalink/t3viewhelper:backward-compatible-syntax@main)
-   [Keeping HTML tags within translations](https://docs.typo3.org/permalink/t3viewhelper:keeping-html-tags-within-translations@main)
-   [Displaying translated labels with placeholders](https://docs.typo3.org/permalink/t3viewhelper:displaying-translated-labels-with-placeholders@main)
-   [Inline notation with arguments and default value](https://docs.typo3.org/permalink/t3viewhelper:inline-notation-with-arguments-and-default-value@main)
-   [The translation ViewHelper in console/CLI context](https://docs.typo3.org/permalink/t3viewhelper:the-translation-viewhelper-in-console-cli-context@main)
-   [Arguments of the f:translate ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-f-translate-viewhelper@main)

> [!NOTE]
> <!-- TODO: no Markdown rendering for "versionadded" -->
>
> The translate ViewHelper supports translation domains,
> a short and convenient way to reference language labels without
> requiring LLL: paths or extension names.Translation domain syntax is the recommended and future-proof way
> to reference translations.The older LLL: and extension arguments are still valid for
> backward compatibility.All existing syntax remains fully supported, ensuring backward
> compatibility. The new syntax can be adopted incrementally within a
> project, and both old and new forms can coexist in the same template.

## Using translation domains {#typo3-fluid-translate-example-domain}

The translation domain syntax is the **recommended** way to
reference labels. It allows concise and clear label identifiers, without using
`LLL:` paths and extension names.

There are two equivalent ways to use domains:

1.  **Provide the domain as a separate argument** and only reference the identifier
    (recommended):

    ```html
    <f:translate domain="backend.toolbar" key="save" />
    <f:translate domain="my_extension.messages" id="greeting.hello" />
    ```
1.  **Use the combined domain + identifier syntax** in the `key`/`id` arguments:

    ```html
    <f:translate key="backend.toolbar:save" />
    <f:translate id="my_extension.messages:greeting.hello" />
    ```

-   The **domain** syntax is the preferred syntax for all new templates.
-   If both `domain` and `extension` are set, **the domain property takes precedence**.
-   The older `key="LLL:EXT:..."` and `extension` arguments are still supported for
    backward compatibility.

> [!TIP]
> Run the console command to list all translation domains and their language
> file mapping:
>
> ```bash
> vendor/bin/typo3 language:domain:list
> ```
>
> This will help you find your domains when migrating from `LLL:` paths
> to the new translation domain syntax.

## Backward compatible syntax {#typo3-fluid-translate-example-backward}

The following forms are still supported for older templates and extensions.
New code should use domains instead.

### Short key - Usage in Extbase {#typo3-fluid-translate-example-key-only}

The [key](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-translateviewhelper-key@main)
argument on its own works in the Extbase context.

**Fluid**

```html
<f:translate key="domain_model.title" />
```

**Language file example**

**packages/my_extension/Resources/Private/Language/locallang.xlf**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext"
        original="EXT:my_extension/Resources/Private/Language/locallang.xlf"
        date="2020-10-18T18:20:51Z" product-name="my_extension"
    >
        <header />
        <body>
            <trans-unit id="domain_model.title">
                <source>My Model</source>
            </trans-unit>
        </body>
    </file>
</xliff>

```

Alternatively, you can use `id` instead of `key` to produce the same output.
If both `id` and `key` are set, `id` takes precedence.

If the translate ViewHelper is used with only the language key, the template
**must** be rendered in an Extbase request, usually from an Extbase
controller action. The default language file must be located in the same
extension as the Extbase controller and must be saved in
`Resources/Private/Language/locallang.xlf`.

### Short key and extension name {#typo3-fluid-translate-example-key-extension}

If the ViewHelper is called from outside Extbase, the extension name or the
full `LLL:` key reference must be passed as arguments.

```html
<f:translate key="domain_model.title" extensionName="my_extension" />
```

The default language file must be located in
`Resources/Private/Language/locallang.xlf` of the extension.

<!-- TODO: no Markdown rendering for "versionchanged" -->

The translation domain syntax is now the recommended way
to reference labels. The extension argument still works for
backward compatibility.

### Full `LLL:` reference key {#typo3-fluid-translate-example-key-full}

Using the `LLL:` language reference syntax, a language key from any `.xlf`
file can be used.

```html
<f:translate
    key="LLL:EXT:my_extension/Resources/Private/Language/my_locallang.xlf:domain_model.title"
/>
```

> [!NOTE]
> This legacy form remains fully supported for backward compatibility.
> Domain syntax should be used for all new templates.

## Keeping HTML tags within translations {#typo3-fluid-translate-example-html}

HTML in language labels can be used when you surround the translate ViewHelper
with a ViewHelper that allows HTML output, such as the
[Sanitize.html ViewHelper \<f:sanitize.html>](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-sanitize-html@main)
in the backend or the [Format.html ViewHelper \<f:format.html>](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-format-html@main)
in the frontend.

**Fluid**

**packages/my_extension/Resources/Private/Templates/Message/Show.fluid.html**

```html
<f:format.html>
    <f:translate
        domain="my_extension.messages"
        key="content.withHtml"
    />
</f:format.html>
```

**Language file example**

**packages/my_extension/Resources/Private/Language/locallang.xlf**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext"
        original="EXT:my_extension/Resources/Private/Language/locallang.xlf"
        date="2020-10-18T18:20:51Z" product-name="my_extension"
    >
        <header />
        <body>
            <trans-unit id="myKey">
                <source>
                    <![CDATA[By default, ordered and unordered lists are formatted
                    with bullets and decimals. <br>
                    By adding <code>class="list-unstyled"</code> to the ol or ul tag, it
                    is possible to structure content in list form without the
                    typical list styling.]]>
                </source>
            </trans-unit>
        </body>
    </file>
</xliff>

```

The entry in the `.xlf` language file must be surrounded by `<![CDATA[...]]>`.

> [!WARNING]
> When allowing HTML tags in translations, ensure all translators are
> educated about [Cross-site scripting (XSS)](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Security/TypesOfThreats/Index.html#security-xss).

## Displaying translated labels with placeholders {#typo3-fluid-translate-example-placeholder}

**Fluid**

**packages/my_extension/Resources/Private/Templates/Message/Show.fluid.html**

```html
<f:translate
    domain="my_extension.domainmodel"
    key="title"
    arguments="{0: '{myVariable}'}"
/>

Or with several numbered placeholders:

<f:translate
    domain="my_extension.domainmodel"
    key="title"
    arguments="{1: '{myVariable}', 2: 'Some String'}"
/>
```

**Language file example**

**packages/my_extension/Resources/Private/Language/locallang.xlf**

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext"
        original="EXT:my_extension/Resources/Private/Language/locallang.xlf"
        date="2020-10-18T18:20:51Z" product-name="my_extension"
    >
        <header />
        <body>
            <label index="domain_model.title">Title of: %s</label>
            <trans-unit id="domain_model.description">
                <source>Some text about a %1$s and a %2$s.</source>
            </trans-unit>
        </body>
    </file>
</xliff>

```

The placeholder `%s` is used to insert dynamic values, passed as the parameter
[arguments](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-translateviewhelper-arguments@main)
to the translate ViewHelper. If `%s` appears multiple times, it references
subsequent array entries in order.

To avoid dependency on order, use indexed placeholders like `%1$s`. This
explicitly refers to the first value and ensures that it is treated as a string
(`$s`). This method is based on PHP’s
[vsprintf function](https://www.php.net/manual/en/function.vsprintf.php),
which allows for more flexible and readable formatting.

## Inline notation with arguments and default value {#typo3-fluid-translate-example-inline}

Like all the other ViewHelpers, the translate ViewHelper can be used with
[Inline syntax](https://docs.typo3.org/other/typo3fluid/fluid/main/en-us/Syntax/ViewHelpers.html#viewhelper-inline-notation).

```html
{f:translate(domain: 'my_extension.messages', key: 'animal.sentence', arguments: {0: 'dog', 1: 'fox'}, default: 'default value')}
```

This is especially useful if you want to pass the translated label to another
ViewHelper, for example, as the `alt` parameter of an image:

```html
<f:image src="EXT:my_extension/Resources/Public/icons/Edit.svg"
    alt="{f:translate(domain: 'my_extension.icons', key: 'edit', default: 'Edit')}"
/>
```

## The translation ViewHelper in console/CLI context {#typo3-fluid-translate-example-console}

The translation ViewHelper determines the target language based on the current
frontend or backend request.

If you are rendering your template from a console/CLI context, for example,
when you [Send emails with FluidEmail](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Mail/Index.html#mail-fluid-email),
use the argument [languageKey](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-translateviewhelper-languagekey@main)
to specify the desired language for the ViewHelper:

**packages/my_extension/Resources/Private/Templates/Email/Salutation.fluid.html**

```html
Salutation in Danish:
<f:translate
    domain="my_extension.messages"
    key="salutation"
    languageKey="da"
/>

Salutation in English:
<f:translate
    domain="my_extension.messages"
    key="salutation"
    languageKey="default"
/>
```

## Arguments of the f:translate ViewHelper {#typo3-fluid-translate-arguments}

<!-- TODO: no Markdown rendering for "versionadded" -->

The domain argument was added. It selects a translation domain
and should be preferred over extension or extensionName.
When both are given, domain takes precedence.

-   **arguments**

    -   *Type:* array

    Arguments to be replaced in the resulting string

-   **default**

    -   *Type:* string

    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

-   **domain**

    -   *Type:* string

    Translation Domain to be used for the ID/Key. Takes precedence over "extensionName". Should also be used over "extensionName".

-   **extensionName**

    -   *Type:* string

    UpperCamelCased extension key (for example BlogExample)

-   **id**

    -   *Type:* string

    Translation ID. Same as key.

-   **key**

    -   *Type:* string

    Translation Key

-   **languageKey**

    -   *Type:* string

    Language key ("da" for example) or "en" to use. Also a Locale object is possible. If empty, use current locale from the request.
