Kirby Content Translator

:new: Kirby Content Translator

@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!

:point_right: GitHub - johannschopplich/kirby-content-translator: 🌐 Kirby Panel plugin for field and blocks translation with DeepL or other services

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
2 Likes

Thanks for the great plugin! Unfortunately it doesn’t work for layout fields with type: layout.
Can you fix that?

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.

Wow ! It’s working like a charm ! Congratulation and thank you for this plugin

Bye

@johannschopplich

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:

columns:
  main:
    width: 1/2
    sections:
      contentheadline: sections/contentheadline
      contentTranslator:
        type: content-translator
      blocks: sections/blocks

the /sections/blocks.yml looks like this:

type: fields
fields:
  blocks:
    label: Inhalte
    type: blocks
    fieldsets:
      - heading
      - text
      - buttonlink

buttonlink is a custom block configured like this in a kirby plugin:

name: Button
icon: status-listed
wysiwyg: true
fields:
  linktype:
    type: radio
    label: Typ
    options:
      internal: Intern
      external: Extern
      download: Download
  icon:
    label: Icon
    type: icon
    folder: assets/icons
    max: 1
    search: true
  label:
    type: text
    label: Beschriftung
  href:
    type: url
    label: Link
    when:
      linktype: external
  page:
    type: pages
    label: Seite
    multiple: false
    when:
      linktype: internal
  file:
    type: files
    label: Datei auswählen ...
    multiple: false
    when:
      linktype: download

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!?

Thanks in advance!

Correction.

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.