View Button & Field Configuration
Kirby Content Translator can be added to Panel views via a view button (recommended) or a field. Both approaches share their configuration properties and can be used together.
View Button Configuration
The Content Translator view button can be added to any Panel view (site, page, file) alongside the default buttons like the languages dropdown. It provides a dropdown menu with translation actions.
Our Studio
Basic Setup
To add the content-translator button to a Panel view, set the buttons option in the corresponding blueprint. Listing buttons replaces Kirby's defaults, so name the ones you want to keep – the default set differs per model. content-translator goes wherever it suits the view:
buttons:
- open
- preview
- content-translator
- languages
buttons:
- open
- preview
- settings
- content-translator
- languages
- status
buttons:
- open
- settings
- content-translator
- languages
Add the Button to Every View
To add the button to every site, page, or file view without editing each blueprint, set Kirby's panel.viewButtons option. It replaces the defaults the same way a blueprint list does, and a blueprint that sets buttons wins over it:
return [
'panel' => [
'viewButtons' => [
'site' => ['open', 'preview', 'content-translator', 'languages'],
'page' => ['open', 'preview', 'settings', 'content-translator', 'languages', 'status'],
'file' => ['open', 'settings', 'content-translator', 'languages']
]
]
];
The option takes the same list or map form as a blueprint, so the properties below can be set here too. Only cascade has to stay in the blueprint.
A language key puts the button on Kirby's language view, where it translates language variables – see Language Variables.
Pass Props to the Button
Switch the list to a map when you need to pass props. A map replaces the defaults the same way a list does, so keep naming every button you want – true renders one with its own defaults:
buttons:
open: true
preview: true
settings: true
content-translator:
title: true
slug: true
excludeFields:
- description
languages: true
status: true
A site or file blueprint names its own buttons in the map, as listed under Basic Setup.
Field Configuration
As an alternative to the view button, you can add a Content Translator field to your blueprint. The field displays translation controls directly within the page content area.
Basic Setup
Add the Content Translator field to a site, page, or file blueprint:
fields:
contentTranslator:
type: content-translator
The field runs the same translation as the view button but is placed within the blueprint layout. It also accepts one property the view button does not: systemPrompt.
This is how the basic field will look in the default language:
Content Translator ×
When switching to secondary languages, the field buttons will change to Import and Translate:
Content Translator ×
Pass Props to the Field
Configure the field behavior with props:
fields:
contentTranslator:
type: content-translator
title: true
slug: true
kirbyTags:
link:
- text
- title
image:
- alt
- caption
Available Properties
buttons.content-translator (view button) or fields.contentTranslator with type: content-translator (field) – see the scaffolds above.label String
Custom label for the Content Translator view button or field. The default depends on the Panel language – in English, "Translator" for the view button and "Content Translator" for the field.
To change the label to "Translate":
label: Translate
This property is per-blueprint only. To rename the button or field project-wide, override the johannschopplich.content-translator.viewButton.label and johannschopplich.content-translator.label keys under Localization.
importFrom String
Controls import direction. Set to all to allow importing from any language to any language, including overwriting the default language with content from secondary languages.
Default: none (secondary languages import from the default language only)
importFrom: all
The button text will indicate that importing from secondary languages is allowed:
Content Translator ×
importFrom: all with caution. It also enables the Translate action in the default language.import Boolean
Shows the import actions.
Default: true
To hide them, set import to false:
import: false
batch Boolean
Enable or disable batch translation (translating to multiple languages at once).
Default: true
This property only applies in the default language, where the batch action appears.
A batch run reads the saved content of the default language, so save your changes there before starting one. A language with unsaved changes is not translated, so save or discard them first. Translation Results lists what a run reports per language.
To hide the batch action, set batch to false:
batch: false
title Boolean
Include the model title in import and translation operations. Without it, the title stays as it is, which on a page without its own translation is the default language's title.
Default: false
title: true
slug Boolean
Similar to the title property, the model slug can be included in import and translation operations. Kirby builds the slug from the translated title with the target language's slug rules, so slug: true also sends the title to the provider – the page keeps its title unless title: true is set as well. The default language's slug never changes, since that would rename the page folder.
Default: false
slug: true
title property is ignored on file models. A file has no title of its own, and a field named title in a file blueprint is left out of import and translation, so name such a field differently, for example caption. The slug property is ignored on file and site models, since file names remain language-agnostic by design. It is also ignored on the home and error pages, whose slugs Kirby resolves by route.fieldTypes Array
Specify which field types take part in import and translation. A container type in the list opens its contents but does not translate them, so a text field inside a blocks field needs both blocks and text listed.
Default field types:
blockslayoutlistobjectstructuretagstexttextareawritermarkdown(from the markdown field plugin)table(from the table field plugin)
Only the default types are translated: any other type in the list, such as pagepicker, is copied on import, but a translation leaves its value as it is.
For example, to include only text and textarea fields in the translation:
fieldTypes:
- text
- textarea
code block is never translated, and a block hidden in the Panel is skipped.translate: false is set on a field, it will be ignored by the translation process, regardless of the fieldTypes configuration.includeFields Array
Specify the fields to include in import and translation operations. Names are matched case-insensitively. The list narrows the blueprint's top-level fields; everything nested inside a block, structure, layout, or object is reached through its top-level parent rather than by its own name. The fieldTypes property is still respected.
Default: [] (all eligible fields)
For example, to include only company and author fields in the translation:
includeFields:
- company
- author
excludeFields Array
Specify the top-level fields to exclude from the import and translation process. Useful to drop specific fields while still including all fields of certain types via fieldTypes.
Default: [] (no field is excluded)
For example, to exclude description and summary fields from translation:
excludeFields:
- description
- summary
kirbyTags Object
Configure selective translation of KirbyTag types and its attributes (e.g., link text, image alt text).
Default: none (no KirbyTag attribute is translated)
kirbyTags:
link: [text, title]
image: [alt, title, caption]
file: [text, title]
email: [text, title]
video: [caption]
For the full per-tag attribute reference and translation behavior, see the KirbyTags Configuration guide.
cascade String | Array
Also translate the pages and files a Kirby query names, such as the host's own files or the module pages of a page builder. The value is one Kirby query or a list of them. The models they find are always saved directly.
cascade: page.files
This property is per-blueprint only; there is no global counterpart. See Translate Related Pages and Files for the queries, the rules for titles and unsaved changes, and a Kirby Modules example.
systemPrompt String
Override the AI translation system prompt for this specific field, taking precedence over the global ai.systemPrompt config option. Fields only – the view button does not declare this property and silently ignores it, so a per-view override has to go through the global option.
systemPrompt: >
You are a medical translator.
Preserve clinical terminology
and abbreviations.
theme String
Controls the visual appearance and color theme of the button. View button only – the field does not declare this property and silently ignores it.
Default: notice-icon
Options: passive, white, info, positive, warning, notice, negative, love, aqua, purple, dark, *-icon variants (e.g., positive-icon, negative-icon)
theme: positive-icon
Configuration Precedence
Properties are applied in the following order (later values override earlier ones):
- Default values (built into the plugin)
- Global configuration (in
config.php) - View button & field props (in blueprints, or for the view button in
panel.viewButtons, which a blueprintbuttonslist replaces)
return [
'johannschopplich.content-translator' => [
'fieldTypes' => ['text', 'textarea'], // Applied globally
'title' => true
]
];
fields:
contentTranslator:
type: content-translator
fieldTypes: # Overrides global config
- blocks
- text
- textarea
# title: true inherited from global config
buttons:
content-translator:
title: false # Overrides global config
Localization
Override the plugin's default Panel labels in the translations extension of a site plugin. Useful when "Synchronize" reads better than "Import" for your editors, or when your project uses a language the plugin doesn't ship translations for.
use Kirby\Cms\App as Kirby;
Kirby::plugin('site/translations', [
'translations' => [
'en' => [
'johannschopplich.content-translator.import' => 'Synchronize'
]
]
]);
Name the folder so that it sorts after kirby-content-translator, as translations does.
translations/en.json for the full list of translation keys.