Translation
TranslationDeepL

DeepL

Inject the DeepL API as a translation provider into directive @strTranslate, to translate a field value to over 30 languages.

Description

Make DeepL's API available as a translation provider in directive @strTranslate.

Add directive @strTranslate to any field of type String, to translate it to the desired language.

For instance, this query translates the post's title and content fields from English to French using the DeepL API:

{
  posts {
    title @strTranslate(
      from: "en",
      to: "fr",
      provider: deepl
    )
    
    content @strTranslate(
      from: "en",
      to: "fr",
      provider: deepl
    )
  }
}

List of languages

You can translate your content to any of the following languages:

CodeLanguage
ARArabic
BGBulgarian
CSCzech
DADanish
DEGerman
ELGreek
ENEnglish (all English variants)
ESSpanish
ETEstonian
FIFinnish
FRFrench
HUHungarian
IDIndonesian
ITItalian
JAJapanese
KOKorean
LTLithuanian
LVLatvian
NBNorwegian Bokmål
NLDutch
PLPolish
PTPortuguese (all Portuguese variants)
RORomanian
RURussian
SKSlovak
SLSlovenian
SVSwedish
TRTurkish
UKUkrainian
ZHChinese (all Chinese variants)

DeepL API Configuration

In order to use DeepL, it is mandatory to provide the Plan used (Free or Pro) and the API key, via tab "Plugin Management => DeepL API" on the Settings page.

Create the API key in your DeepL's account, following the instructions here.

Then follow one of the methods below to input the value.

By Settings

Input the Plan and API key in the corresponding inputs in the Settings page, and click on "Save Changes (All)":

Setting DeepL's plan
Setting DeepL's plan
Setting DeepL's API key
Setting DeepL's API key

In wp-config.php

Add constants GATOGRAPHQL_DEEPL_PLAN and GATOGRAPHQL_DEEPL_API_KEY in wp-config.php:

define( 'GATOGRAPHQL_DEEPL_PLAN', 'pro' /* or 'free' */ );
define( 'GATOGRAPHQL_DEEPL_API_KEY', '{your API key}' );

By environment variable

Define environment variables DEEPL_PLAN and DEEPL_API_KEY.