DeepL
DeepL is a machine translation service with a focus on European languages; see its language list for what it covers. DeepL offers a free tier – see DeepL API pricing for current limits.
Setup
To translate with DeepL, add your API key to the global configuration:
return [
'johannschopplich.content-translator' => [
'DeepL' => [
'apiKey' => 'your-deepl-api-key'
]
]
];
Request Options
Pass any of DeepL's translate text parameters through requestOptions:
return [
'johannschopplich.content-translator' => [
'DeepL' => [
'requestOptions' => [
// Lean towards formal language
'formality' => 'more'
]
]
]
];
text, source_lang, and target_lang are ignored here – the texts and languages of the current translation always win. Use targetLanguageOverrides to pin a target code.Supported Languages
The plugin mirrors DeepL's supported languages.
Regional variants exist as target languages only:
- German: Germany (DE-DE), Switzerland (DE-CH)
- English: British (EN-GB), American (EN-US)
- French: France (FR-FR), Canada (FR-CA)
- Portuguese: Brazilian (PT-BR), European (PT-PT)
- Spanish: European (ES), Latin American (ES-419)
- Chinese: Simplified (ZH-HANS), Traditional (ZH-HANT)
LC_ALL locale. A language code of de-ch receives DE-CH, and so does a plain de with the locale de_CH.UTF-8. The code wins when the two disagree, so a Swiss site keeps Swiss German on a server that only has de_DE installed.Language Code Overrides
When your Kirby language code names no language DeepL supports, translating into it fails with Cannot resolve a DeepL target language – its locale can only sharpen the code into a regional variant, never stand in for it. A cn language therefore stays unresolvable on a zh_CN.UTF-8 server; map the code to a DeepL target code instead:
return [
'johannschopplich.content-translator' => [
'DeepL' => [
'targetLanguageOverrides' => [
// Kirby language code => DeepL target code
'cn' => 'ZH-HANS',
'no' => 'NB'
]
]
]
];
An override outranks both the language code and the locale, and isn't checked against the supported languages – so it also carries a code DeepL releases after this version.