Kirby Content Translator supports translation of KirbyTags while preserving their structure and functionality. You can configure which types of KirbyTags and which specific attributes within those tags should be translated, giving you fine-grained control over the translation process.
When the plugin encounters KirbyTags in textarea or markdown fields, it can either:
The plugin uses Kirby's built-in KirbyTag parser to safely decode, translate, and reconstruct tags without breaking their syntax.
Add the kirbyTags option to your plugin configuration to enable selective translation. You can specify which KirbyTag types to translate and which attributes within those tags should be processed. Here's an example configuration:
return [
'johannschopplich.content-translator' => [
'kirbyTags' => [
'link' => ['text', 'title'], // Translate link text and title
'image' => ['alt', 'title', 'caption'], // Translate image descriptions
'file' => ['text', 'title'], // Translate download link text
'email' => ['text', 'title'], // Translate email link text
'video' => ['caption'], // Translate video captions
// Add more tag types as needed
]
]
];
When using the Content Translator view button or section, you can also configure KirbyTags directly in your blueprint. This allows you to define which tags and attributes should be translated per section:
type: content-translator
kirbyTags:
# Translate link text and title in `(link: ...)` KirbyTags
link:
- text
- title
# Translate image alt text and title in `(image: ...)` KirbyTags
image:
- alt
- title
- caption
# Translate file text and title in `(file: ...)` KirbyTags
file:
- text
- title
# Translate email text and title in `(email: ...)` KirbyTags
email:
- text
- title
# Translate video caption in `(video: ...)` KirbyTags
video:
- caption
For example, this configuration translates the text and title attributes of link tags. Other attributes, such as the URL, will remain unchanged to ensure that links continue to function correctly after translation.
The content might look like this before and after translation (from English to German):
-(link: https://example.com text: Visit our website title: To homepage)
+(link: https://example.com text: Besuchen Sie unsere Website title: Zur Startseite)
kirbyTags option is not configured, the plugin excludes all KirbyTags from translation by default. This prevents breaking existing content and ensures URLs, filenames, and other technical attributes remain intact.The configuration is an associative array where:
link, image, file)Common translatable attributes:
text – Link text, button text, display texttitle – Tooltips, titles, hover textalt – Image alternative textcaption – Image or video captionsvalue – The main value of a KirbyTag (use with caution)In advanced scenarios, you may want to translate the entire value of a KirbyTag, such as a quote with both the quote text and author. To include the main value of a KirbyTag in the translation, add value to the attributes array:
return [
'johannschopplich.content-translator' => [
'kirbyTags' => [
'quote' => ['value', 'author'] // Translate both the main quote and author
]
]
];
The plugin includes error handling for KirbyTags to ensure that translation does not break content:
<span translate="no"> to prevent breaking.