Skip to main content

Auto-translate content with AI on save

Overview

With Kuroco's AI automatic processing, you can run AI processing automatically when content is saved.
In this tutorial, on a site with localization (multi-language) enabled, you implement a feature that translates content entered in Japanese (the primary language) into English (a secondary language) with AI and sets it automatically when the content is saved.

As an advanced step, this tutorial also explains how to chain translations from English (a secondary language) into other secondary languages (such as Korean and Portuguese), and how rules are executed and ordered when multiple rules are configured.

caution

Translations with AI automatic processing are counted under the "AI processing unit" item. Processing many pieces of content or several secondary languages at once increases the AI processing unit fee accordingly. After setting this up, do not run it on a large amount of content right away. We recommend first trying it on a small amount of content to check the translation results and the AI processing unit fee, and then moving on to full-scale operation.

What you will learn

You will implement AI auto-translation with the following steps.

Prerequisites

  • A Kuroco site has been created
  • Localization (multi-language) is available

1. Enable localization

To set up AI translation into a secondary language, enable localization in advance.

Click [Environment settings] -> [Localization].

Image from Gyazo

Turn on [Enable] for [Multi-language settings], and select the primary and secondary languages. Here, configure them as follows.

ItemValue
Primary languageJapanese
Secondary languageEnglish

Image from Gyazo

Click [Update] to save the settings.

info

When you add a secondary language, a language tab appears on the content edit screen, and you can save data per language. For details on secondary-language behavior, see About secondary languages.

2. Create a content structure

Create a content structure with the body field to translate. When localization is enabled, you can save a value per language for the same field.

Click [Content structure], then click [Add].

Image from Gyazo

Enter the following.

ItemValue
Content structure nameTranslation test

Next, add the following extended field.

SlugField nameField setting
bodyBodyText area

Image from Gyazo

Click [Add] to save the content structure.

3. Configure AI automatic processing

Open the content structure you created, and click [AI automatic processing] in the left side menu.

Image from Gyazo

Enable AI post-processing

Turn on [Enable] for [AI post-processing].

Image from Gyazo

Add a rule

Click [Add rule], and configure a rule that translates from Japanese into English as follows.

ItemValue
PromptSee below
Execution timingOn create and update
Creation statusPublished
Input languageJapanese
Output languageEnglish

Example prompt:

Translate the input into natural English. Keep HTML tags and line-break structure unchanged, and translate only the text. Return only the translation, with no explanation or preamble.

Image from Gyazo

Click [Update] to save the settings.

info

The target language is specified with [Input language] and [Output language]. The content of the specified [Input language] is translated and saved as the secondary-language data of the [Output language].

4. Verify the behavior

Create new content from the content structure you configured.

Click [Content structure], click [List] for [Translation test], then click [Add].

Enter Japanese text in the Body field of the primary language (Japanese), and click [Add].

FieldExample value
TitleKurocoについて
BodyKurocoはヘッドレスコンテンツ管理システムです。

Image from Gyazo

After saving, switch the language tab on the content edit screen to [English]. Confirm that the English text translated by AI is automatically set in the Body field.

Image from Gyazo

info

AI post-processing runs in the background after content is saved. It may take some time for the translation result to be reflected.

This completes the AI auto-translation implementation.

Advanced: translate from English into other secondary languages

You can also chain translations from English (a secondary language) into other secondary languages (such as Korean and Portuguese).
With this setup, when the Japanese-to-English translation is not as expected, you can manually correct only the English data and then re-translate the other secondary languages from it.

info

To use this setup, in 1. Enable localization you must add not only English but also the secondary languages to translate into (such as Korean and Portuguese).

Add a rule per secondary language

Under [AI post-processing], click [Add rule] and register one rule per target secondary language. Combining multiple output languages into a single rule may not produce the intended translation.

Input languageOutput languageExecution timingCreation status
EnglishKoreanOn create and updatePublished
EnglishPortuguese (BR)On create / updatePublished

Example prompt (rule for Korean):

Translate the input into natural Korean. Keep HTML tags and line-break structure unchanged, and translate only the text. Return only the translation, with no explanation or preamble.

Register the Portuguese rule in the same way, specifying the target language in the prompt.

Image from Gyazo

Click [Update] to save the settings.

Rule execution order and conditions

When multiple rules are registered, they are executed under the following conditions.

  • Only rules whose [Input language] matches the saved language are executed. When you save in Japanese, only the rule whose [Input language] is Japanese (Japanese to English) runs; rules whose [Input language] is English do not run at this point.
  • When a translation result is saved as the secondary language of its [Output language], rules whose [Input language] is that language run next. When the English translation result is saved, the rules whose [Input language] is English (English to Korean, English to Portuguese) run next. Through this chaining, translation proceeds in the order Japanese to English to the other secondary languages.
  • A language that has already been used as a translation source is not translated again. This prevents translation from repeating between the same languages. Therefore, even if you set the same language for [Input language] and [Output language], translation does not repeat indefinitely.
  • A rule whose input has not changed since the previous run is not re-executed.
info

Translation into secondary languages runs sequentially after the English translation is saved. It may take some time until the result is reflected in all secondary languages.


Support

If you have any other questions, please contact us or check out Our Slack Community.