Automatic translation

When the feature automatic_translation is activated for a node, pages, and texts can be automatically translated by utilizing a translation service.

1 Activating Feature

The feature must be generally activated:

conf/features.yml

feature:
  automatic_translation: true

Changing the general setting for the feature requires the CMS to be restarted or the configuration to be reloaded (e.g.: via the Administrator UI).

Once the feature is generally activated, it can be turned on and off for each node using the UI by a user with edit permission on the node:

  1. Choose Features from the Context Menu of the Node in the tree.
  2. Activate the checkbox next to automatic_translation
  3. Click OK to activate the feature

If the option Features is missing from the context menu, or the feature automatic_translation is not listed in the features activation dialog, the feature automatic_translation is probably generally not activated.

2 How the feature works

Automatic translation is a feature that can be used to translate existing pages automatically by utilizing an external translation service. When configured properly the automatic translation can be used directly in the UI in the translation modal. Furthermore, this feature can be used directly via the REST API (see API reference) to translate pages or simple text.

3 Requirements:

The following requirements need to be satisfied:

  • The feature needs to be enabled
  • A valid license for the feature ‘TRANSL
  • An implementation of the TranslationInterface in the classpath
  • Valid configuration containing the implementation class, API token, etc (see below for an example).
  • An active account for the translation API in use (e.g. DeepL account with remaining quota, etc.).

4 Service Implementation

The translation service implementation is defined via an interface, thus the concrete implementation can be any implementation of the TranslationInterface. The concrete implementation gets picked up by the Java ServiceLoader. Therefore, the implementation needs to be in the Java classpath. When using the CMS in a non-Docker environment, the classpath must contain a writeable directory. The CMS will create a service definition file containing the implementation specified in the configuration. Thereby the implementation is bound to the interface. Gentics provides a reference implementation for the DeepL translation service. To to use it, one has to bind the implementation to the TranslationInterface (an example is provided in the configuration chapter). Instead of the DeepLTranslationService a custom implementation can be used as well.

5 Configuration

Configuration example for DeepL:

config.yml

automatic_translation:
  implementation: com.gentics.contentnode.translation.DeepLTranslationService
  auth:
    token: <api-token>
  language:
    en: US
    pt: BR

The language configuration is implementation-specific and needed as DeepL offers multiple flavors for English and Portuguese.