How to Activate the Mastodon v4 DeepL API Text Translation Service
DeepL is a machine translation service with a REST API supported by the Mastodon social networking software. As of the Mastodon v4 release, instance administrators can configure support for user post translations between the following languages:
- Bulgarian
- Chinese (simplified)
- Czech
- Danish
- Dutch
- English (British)
- English (American)
- Estonian
- Finnish
- French
- German
- Greek
- Hungarian
- Indonesian
- Italian
- Japanese
- Latvian
- Lithuanian
- Polish
- Portuguese (Brazilian)
- Portuguese (European)
- Romanian
- Russian
- Slovak
- Slovenian
- Spanish
- Swedish
- Turkish
- Ukrainian
[Source: DeepL Translation Languages]
How to Configure DeepL Translations on Your Mastodon Instance
Sign Up for the DeepL REST API Service
At the time of this writing, DeepL includes a free plan that supports translations of up to 500,000 characters per month. Paid plans are available for instances that require translation volumes over this limit.
Sign up for a DeepL API account at this sign-up page, then copy your account API KEY from the https://www.deepl.com/account/summary page.
Configure Mastodon to Use the DeepL REST API
Navigate to the Mastodon directory on your server and open your instance .env.production
file in a text editor. Add the following environment variables to the file, replacing [API KEY]
with the API KEY that you copied from the DeepL account summary page in the step above:
DEEPL_API_KEY=[API KEY]
DEEPL_PLAN=free
Restart Your Mastodon Services
Restart your Mastodon services by executing the following commands on your server:
$ systemctl restart mastodon-sidekiq
$ systemctl reload mastodon-web
Confirm Activation of the DeepL Translation Service
The Mastodon v2 JSON API returns a translation
JSON field at the following public API endpoint:
https://[your instance domain]/api/v2/instance
You should receive "translation":{"enabled":true}}
in the response configuration
field if your instance is correctly configured to translate Mastodon posts.
Instance users will see a “Translate” UI text link in their posts if the posting user properly configures the post language:
The text is replaced with translated text inline when the user clicks the 'Translate' link.