LibreTranslate with Cloudron Mastodon Server
shanelord01 last edited by
OK I have LT setup and running, API key configured.
How do I now edit the Cloudron Mastodon config to use it?
shanelord01 last edited by shanelord01
@shanelord01 OK - worked it out.
- Open the web UI for LibreTranslate after setting it up.
- In the "Request" box, there is a line with "const res = await fetch("https://translate.your.domain/translate", "
- Copy the main domain URL (ie https://translate.your.domain" )without the /translate and without quotation marks.
- Open your Cloudron Mastodon app, and open its file manager and edit "env.production"
- At the bottom, add the "#translate section" below here:
# Optionally change default language # DEFAULT_LOCALE=en # translate LIBRE_TRANSLATE_ENDPOINT=https://translate.your.domain LIBRE_TRANSLATE_API_KEY=YOUR_API_KEY
Save this. Restart the Mastodon app.
If you don't have your API key, open the LibreTranslate Cloudron App Terminal, and issue:
su - cloudron -c 'ltmanage keys --api-keys-db-path /app/data/api_keys.db add 120'
You'll get a key like "f67d5afe-aa14-4d37-90f7-f7d9636b721e" in response - use the one you got in reponse.
Optional; set your default language:
# Optionally change default language DEFAULT_LOCALE=en
After completing setup and ensuring everything works, if you want to stop people from using the Web UI to translate, you can disable it by editing the LibreTranslate "env.sh" file via its Cloudron File Manager, and adding this (then save env.sh and restart LT):
Note: After doing this I've noted the app is stuck reporting as "Starting" in the Cloudron "My Apps" even though it is running fine. Not sure if this is a health check failing in the Cloudron app? @nebulon Any way to do this without causing this issue?
What do you think about performance and quality? I was quite disappointed and returned to DeepL for now.
shanelord01 last edited by
@nichu42 Compared to what I had (nothing) it's quite good. Speed hasn't been an issue so far - I guess because I over-spec'd the machine it's running on so it has extra CPU available.
@shanelord01 My VPS is at ~ 30% most of the time, but I found the LT API to be awfully slow. Mastodon also gave too many 503 errors (due to timeouts? I don't know). And the translation quality is just too poor compared to DeepL. However, I'm happy to have LT available via Cloudron and will certainly give it another try at a later time. I still like the idea of in-house translation without submitting data to a third party.
@shanelord01 thanks for the great write up! I will try to enable this on our instance as well.
@shanelord01 said in LibreTranslate with Cloudron Mastodon Server:
After doing this I've noted the app is stuck reporting as "Starting" in the Cloudron "My Apps" even though it is running fine
This seems like maybe the box cron job got stuck for some reason. Can you try if
systemctl restart boxfixes the state?
I have enabled this also with our cloudron mastodon instance now and it works mostly. For some reason mastodon does not always show the translate button and sometimes it also shows it for english posts, which then results in a 503 response error, since libretranslate got the request to translate from en -> en which is wrong.
Just sharing this here, to set expectations.
I think Mastodon's translate button only appears if the poster has set a language for his / hear toot that's different from your language settings.
It could be that the LT API relies on the source and destination language settings that are submitted by Mastodon. That could be an explanation for the errors I received, b/c not everyone sets the language correct. Maybe the DeepL API is more flexible here.