mod_translate_deepl

Provides automatic text translation through DeepL as a translation service for Zotonic's mod_translation module.

Configuration

Enable mod_translate_deepl and set the mod_translate_deepl.api_key configuration value to the site's DeepL API key. The integration selects the free API endpoint when the key contains :fx; otherwise it uses the paid API endpoint. No separate endpoint setting is needed.

Grant use.mod_translate_deepl to the user groups allowed to request translations. The observer checks this permission before contacting DeepL. Translation requests send the supplied texts to the external DeepL service using the site's API key.

Translation service

The module handles Zotonic's translate notification and delegates the source language, target language, and list of texts to m_translate_deepl:translate/4. This integrates with the translation option in the admin's add-language dialog.

Texts are sent with HTML tag handling enabled, and text inside code elements is excluded from translation. Omitting the source language requests automatic language detection. Supported language combinations depend on DeepL.

On success the observer returns {ok, TranslatedTexts}. If access is denied, the API key is missing, or the request fails, it returns undefined, leaving the notification available to other translation providers.

Observes

Notifications

observe_translate/2

Request a translation of a list of strings. The resulting translations must be in the same order as the request. This notification is handled by modules that…

Models

Models

m_translate_deepl

Translates lists of texts using the DeepL API and exposes whether an API key has been configured.