Install
Works with Drupal: ^10.2 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
DeepL Provider 1.0.0-beta1 is the first beta and is feature complete for 1.0. It adds model type selection, glossary support and HTML tag handling, declares Drupal 12 compatibility, and now throws the AI module's exceptions when DeepL fails. No new features are planned before 1.0.0, so from here the focus is on testing and fixing bugs. Please try it and report back (see "Testing").
New features
- Model type (#3562179: Add support for model_type): choose the DeepL model type in the settings form: quality optimized, latency optimized or prefer quality optimized. Quality optimized is the default.
- Glossary support (#3549076: Use glossary feature): set a DeepL glossary ID in the settings form. The glossary is applied only when the source language is known and the glossary has entries for the language pair, otherwise it is skipped. A glossary ID can also be given per request through the provider configuration (
glossary_id), in which case it is sent as is without the language pair check. Lookups use DeepL's multilingual glossaries and are cached for the duration of a PHP process. If a lookup fails for a reason other than the glossary not existing, a warning is logged and the text is translated without the glossary. - HTML tag handling (#3632340: Enable tag_handling when translating formatted text): text containing markup is now sent with
tag_handling: html(versionv2), so tags are no longer billed as text or altered. Plain text is unchanged. A caller can set its owntag_handlingvalue, orFALSEto turn it off, for instance to get attributes such astitletranslated. HTML attributes are not translated while tag handling is on. - Drupal 12 (#3594721: Automated Drupal 12 compatibility fixes for ai_provider_deepl 1.0.x-dev): the module now declares compatibility with Drupal 12 (
^10.2 || ^11 || ^12). Its dependencies, AI and Key, may not support Drupal 12 yet, so check their releases before installing on Drupal 12.
Changes that may need your attention
- Errors are now thrown (#3542165: Improve error handling for failed translation API requests): when DeepL fails,
translateText()throws the AI module's exceptions (AiQuotaException,AiRateLimitException,AiSetupFailureException,AiResponseErrorException) instead of returning an empty result with the error message. Custom code that relied on the old behaviour needs to catch these. - Request options (#3632349: translateText() forwards the request tags to DeepL as translation options): the
$optionsargument oftranslateText()is no longer forwarded to DeepL, as it carries the request tags. DeepL options are now taken from the provider configuration, set per request withsetConfiguration()or by aPreGenerateResponseEventsubscriber. - Library requirement:
deeplcom/deepl6. Runcomposer update drupal/ai_provider_deepl--with-dependencies.
Upgrading
There is no update hook. Existing sites should save the DeepL settings form or import the module's configuration to add the new model_type and glossary_id settings. Until then the defaults above apply.
Testing
Testing on real sites is what gets this to a stable release. Please try the beta, especially if you use any of the following, and report what you find
in the issue queue:
- translating formatted (HTML) text, with and without tag handling;
- glossaries, including language pairs the glossary does not cover and a missing source language;
- the model types;
- how your own code handles the thrown AI exceptions;
- Drupal 12, which the module declares compatible with but has so far only been checked statically, and whose dependencies may not support it yet.
Automated tests
Unit tests for the glossary logic and kernel tests for tag handling and the configuration schema.
Credits
Thanks to everyone who contributed code, review and testing: Ilia Nozadze, myriam_b, Renato Heeb, wouters_f, mach3.zone, hartsak, jhuhta.