DeepLStrategy

Translate via DeepL with automatic batching and retries – the default strategy when DeepL is configured.

Translate content via DeepL from PHP. The default strategy when DeepL is configured and no strategy option is set.

Behavior

Units are sent via DeepL::translateMany() (auto-chunked at 50 texts per request). Table cells fall back to single requests to preserve per-cell context. Failed batches keep the source text and trigger content-translator.translate:warning; TranslationException is thrown only when zero units survive.

Selected via 'strategy' => 'deepl'. Also the default fallback when no strategy is configured – DeepL is the always-on default. The AuthException for a missing DeepL.apiKey is raised lazily on the first execute() call.

Construction

public function __construct(DeepL|null $deepL = null)
deepL
DeepL | null
Inject a custom DeepL client – useful in tests or when you want non-singleton instances. Defaults to DeepL::instance().

Usage

config.php
return [
    'johannschopplich.content-translator' => [
        'strategy' => 'deepl',
        'DeepL' => [
            'apiKey' => env('DEEPL_API_KEY'),
        ],
    ],
];
For request-option tuning (formality, glossary IDs, custom tag_handling), see the DeepL client reference.