@dnns24 and I have created a new Kirby Panel plugin to translate content. Works well for writer fields and it even blocks! You define, which fields should be translated.
tl;dr: You can use your Kirby fields as usual, while allowing to translate them with just the click of a button.
Feedback much appreciated!
Getting Started
First, set up the Panel section in one of your blueprints, e.g. a page blueprint and configure the fields that should be synchronised and translated:
The syncableFields key defines the fields that should be copied from the default language to the secondary language when the user clicks the synchronise button.
The translatableFields key defines the fields that should be translated when the user clicks the translate button.
Example:
sections:
contentTranslator:
type: content-translator
# Define field names which should be synced from the default language to other languages
syncableFields:
- text
- description
- tags
# Define field names that should be translated
translatableFields:
- text
- description
# Define the field names inside blocks which should be translated
translatableBlocks:
# Example: translate the `text` field of the `heading` block
heading:
- text
text:
- text
image:
- alt
- caption
I have Kirby 4.0.2 and PHP 8.2.14 and sadly the plugin is not working for me. When I click “Translate”, It writes that the content was translated, but it wasn’t. The same with synchro button.
I suggest that my Deepl API is correct since there is no error message instead of buttons.
Thanks so much for providing this plugin! I managed to set it up easily with deepl api.
It works great within a simple page blueprint looking like this:
columns:
main:
width: 2/3
sections:
fields:
type: fields
fields:
alertheadline:
label: Überschrift
type: text
text:
label: Text
type: textarea
size: medium
sidebar:
width: 1/3
sections:
contentTranslator:
type: content-translator
translatableFields:
- alertheadline
- text
i have one more slightly complex situation though where i cannot get it to work.
I added this block to my config.php:
'johannschopplich.content-translator' => [
'translatableBlocks' => [
'buttonlink' => ['label']
],
// API key for the DeepL free or pro plan
'DeepL' => [
'apiKey' => 'XXX'
]
]
then within another page blueprint i have this setup:
Now when i have a buttonlink block saved and hit the translate button i would expect the label field to get translated, but it doesn’t. Pretty sure my setup is somehow wrong or i misunderstood something but i cannot figure it out.
Maybe you can give a hint to the right direction!?
Using the blueprints as stated above i get the message:
You have to define at least one translatable field for the translatableFields blueprint or in your Kirby configuration.
I don’t really get that. If i have a global config why would i need to have one field defined within the blueprint? That would overwrite any global config if i read correctly.
Also, i cannot not have the type: content-translator-section as there is no buttons there then.
Sorry for the confusion. I did not save the file before reloading the backend.
Problem still exists though.