Translation options for Mastodon
When I first set up translation for my mastodon instance I used LibreTranslate for translation. I did so, because it’s free, open source, and I could run it on my own infrastructure.
However, to save cost, I was running LibreTranslate on the same server as my Elasticsearch instance, and after a while it became clear that this simply didn't have enough memory for both. The result was regular time-outs when I tried to translate posts longer than a dozen or so characters.
The other day I learned that Mastodon also supports DeepL for translation, and I wanted to have a look at how these two translation options compare.
DeepL vs LibreTranslate: Available Languages
Both services support a decent number of languages, but DeepL has a stronger focus on European languages. The following languages are supported by both services:
Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hungarian, Indonesian, Italian, Japanese, Korean, Polish, Portuguese, Russian, Slovak, Spanish, Swedish, Turkish, and Ukrainian.
LibreTranslate additionally supports these languages that are not supported by DeepL:
Arabic, Azerbaijani, Catalan, Esperanto, Hebrew, Hindi, Irish, and Persian.
While DeepL supports these additional languages, that LibreTranslate doesn't support:
Bulgarian, Estonian, Latvian, Lithuanian, Norwegian, Romanian, and Slovenian.
Which one fits your needs will therefore depend on which languages you are mostly seeing in your feed. For me that's mostly German, French, and Spanish, all of which are covered by both services.
One thing to watch out for with Mastodon: If you attempt to translate an unsupported language you’ll get a very basic error message saying simply ‘503 Service unavailable’ - which is the same error you get if you misconfigured your translation service. Not very helpful ...
DeepL vs LibreTranslate: Speed
DeepL is very fast. Translating a 500-character post takes between 0.1-0.3 seconds, even on the free plan. (The Pro plan is supposed to have prioritised execution of requests, so might be even faster.)
Speed for LibreTranslate will depend on the server you are installing it on, so cannot be directly compared to DeepL, but on my server (1 vCPU, 2 GB memory) translating the same 500-character post from German to English took between 3-20 seconds, without obvious reason for the difference in speed.
DeepL vs LibreTranslate: Accuracy / quality of translation
OK, huge caveat here: The only language I speak other than English is German, so I've tested exclusively German to English translation. When comparing these, I have found DeepL to be generally superior to LibreTranslate. LibreTranslate tends to go for a very literal, word-for-word translation. Now, I've done translation in the past, so I do know that there are different schools of thoughts on this. But, whilst both services have produced overall OK and understandable results for me, the DeepL translation has in my opinion been consistently more readable, and easier to understand than the LibreTranslate one.
Here is an example, and I'll let you be the judge which you prefer.
Original German:
LNG-Terminals angeblich unzureichend geschützt: Das sagen die Betreiber
Die deutschen Flüssigerdgas-Terminals sollen laut einem Medienbericht unzureichend gegen Cyberangriffe geschützt sein. Das sagen die Betreiber dazu.
DeepL translation:
LNG terminals allegedly inadequately protected: Here's what operators say
Germany's liquefied natural gas terminals are allegedly inadequately protected against cyberattacks, according to a media report. Here's what operators have to say about it.
LibreTranslate translation:
LNG terminals allegedly insufficiently protected: This is what operators say
According to a media report, German liquefied gas terminals should be inadequately protected against cyber attacks. This is what operators say to.
DeepL vs LibreTranslate: Price
LibreTranslate is free and open source, so you don't pay for LibreTranslate itself. However, you need some servers to run it on, which is not free. Whilst you may be able to run it on a server you already use for something else (e.g. the same server that your Mastodon or Elasticsearch instance runs on), it does require a fair bit of memory and CPU, and in my test simply didn't produce good enough results when doing so. In my testing I needed to run it on a separate server with 1 vCPU and 2GB memory to get reasonable performance, which cost me $14 per month with DigitalOcean, but YMMV.
DeepL on the other hand is a commercial service. They have a free tier that allows translating 500,000 characters per month. If we assume that the average post will be around 250 characters in length, that would allow you to translate 2,000 posts per month. For my single user instance that's more than enough. But if you go over that, you need to pay for a Pro account which has a flat fee of €5 per month, plus €20 per 1 million characters translated.
As such, the total cost with LibreTranslate is likely more predictable, but not necessarily cheaper, than with DeepL, depending on your translation volumes, and the hardware you have available.
DeepL vs LibreTranslate: Setup
The way you configure Mastodon to use either LibreTranslate or DeepL for translation couldn't be more different:
Using Mastodon with LibreTranslate
Setting up LibreTranslate is not trivial, as it's software you need to run on your own server. On the hand, it's well documented, and the fact it required some tinkering with the server, was a plus to me, as I enjoy this sort of stuff.
Using DeepL with Mastodon
In comparison, configuring Mastodon to use DeepL is very simple, and can be done in less than 5 minutes:
To get started, go to the DeepL sign-up page and create your account, then grab your API Key from the Account Summary page. (Unfortunately, you will need a valid payment card for sign up, but they promise they won’t charge you, unless you manually upgrade. I have a debit card with a £0-balance specifically for this purpose, so I’m not bothered about this.)
On your mastodon server, navigate to the mastodon directory, open the .env.production
file in your favourite text editor, and add the following line:
DEEPL_API_KEY={YOUR API KEY}
(If you are using the paid-for Pro plan, also supply DEEPL_PLAN=pro
.)
Finally, restart your server:
sudo systemctl restart mastodon-web
Testing
Once you have enabled either translation service, you can test this by finding a post that is in another language: It should show a 'Translate' button at the bottom left (this is in the webapp - if you are using a mobile app, it's up to the app how they implement it, and some may not support it at all):
When you tap that, you'll get the translation:
Summary
I really wanted to use LibreTranslate for my Mastodon setup: Having software I can run on my own server is more enjoyable to me than using a 3rd party service. However, for my use case DeepL is actually cheaper, faster, and has higher quality translation, so I've switched my Mastodon instance over to using DeepL for translation, and I really like the end result.