Translation reference
Text
Translates simple text or string properties. This is the most common type.
| Type | text |
| Class | Enhavo\Bundle\TranslationBundle\Translation\Type\TextTranslationType |
| Parent | Enhavo\Bundle\TranslationBundle\Translation\Type\TranslationType |
| Options | html, allow_fallback, allow_auto_translate, overwrite, context_groups |
#[Translate('text')]
private ?string $title = null;
#[Translate('text', ['html' => true, 'allow_fallback' => true])]
private ?string $description = null;properties:
title:
type: text
description:
type: text
html: true
allow_fallback: trueallow_fallback
type: boolean default: false
Whether to fall back to the default locale if no translation exists.
allow_auto_translate
type: boolean default: true
Only if true, the auto-translation will be applied to this property.
html
type: boolean default: false
Whether the content should be treated as HTML. This is useful for auto translation.
overwrite
type: boolean default: false
Set to true to overwrite existing translations during auto-translation.
context_groups
type: array default: ['endpoint', 'translation_context']
Use a serialization group to generate an output that is used as a context for auto translation.
Slug
Extends text and is specialized for URL slugs. Supports all options from text.
| Type | slug |
| Class | Enhavo\Bundle\TranslationBundle\Translation\Type\SlugTranslationType |
| Parent | Enhavo\Bundle\TranslationBundle\Translation\Type\TextTranslationType |
#[Translate('slug', ['allow_fallback' => true])]
private ?string $slug = null;properties:
slug:
type: slug
allow_fallback: trueRoute
Translates route objects.
| Type | route |
| Class | Enhavo\Bundle\TranslationBundle\Translation\Type\RouteTranslationType |
| Parent | Enhavo\Bundle\TranslationBundle\Translation\Type\TranslationType |
| Options | allow_null |
#[Translate('route')]
private ?Route $route = null;properties:
route:
type: routeallow_null
type: boolean default: false
Whether null routes are allowed.
File
Translates file or media associations, so different files can be used per locale.
| Type | file |
| Class | Enhavo\Bundle\TranslationBundle\Translation\Type\FileTranslationType |
| Parent | Enhavo\Bundle\TranslationBundle\Translation\Type\TranslationType |
#[Translate('file')]
private ?File $image = null;properties:
image:
type: fileModel
Recursively translates nested model objects and collections. Use this for related entities that themselves contain translatable properties, such as content blocks or tree structures.
| Type | model |
| Class | Enhavo\Bundle\TranslationBundle\Translation\Type\ModelTranslationType |
| Parent | Enhavo\Bundle\TranslationBundle\Translation\Type\TranslationType |
#[Translate('model')]
private Collection $content;properties:
content:
type: model