Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user content translations with configurable backends #19218

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Sep 22, 2022

Server owners can configure a translation backend that enables users to translate public posts. Results are cached, so requests for translating the same string into the same language, even across different posts, does not hit the backend more than once.

Supported backends

  • DeepL (DEEPL_API_KEY and DEEPL_PLAN)
  • LibreTranslate (LIBRE_TRANSLATE_ENDPOINT and LIBRE_TRANSLATE_API_KEY)

Screenshots

Original Translated
image image

REST API

  • POST /api/v1/statuses/:id/translate (supports global lang param, otherwise defaults to user's locale), returns content and detected_source_language. May return HTTP 404 if no backend is configured, or HTTP 503 if the backend fails to translate.

This project was funded through the NGI0 Discovery Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825322.

@Gargron Gargron added api REST API, Streaming API, Web Push API NLnet Funded by NLnet, see https://nlnet.nl/project/Mastodon/ labels Sep 22, 2022
@Gargron Gargron added the ui Front-end, design label Sep 23, 2022
@Gargron Gargron marked this pull request as ready for review September 23, 2022 07:12
app/lib/translation_service/deepl.rb Outdated Show resolved Hide resolved
@shleeable
Copy link
Contributor

shleeable commented Sep 24, 2022

This is excellent.
I've also tested the https://addons.mozilla.org/en-US/firefox/addon/firefox-translations/ and it's pretty good.

seems to be based on https://github.com/browsermt/mts?

@FloatingGhost
Copy link

some gotchas from akkoma's implementation that might be helpful here

not all target languages are locale codes - whilst en does translate for backwards compatibility, deepL recommends using EN-GB and EN-US, whilst they don't say explicitly that they'll remove en, it is possible since it's no longer in their "supported languages" list.

so, you might want to provide users with a setting to select preferred target language, this covers the above, and also since deepl only works on a relatively small subset of languages - a much smaller subset than those supported by mastodon's locale set, and these users will never be able to translate which isn't great

@Tak
Copy link
Contributor

Tak commented Oct 8, 2022

What about advertising this capability to clients in api/v1/instance or elsewhere?

@gllmhyt
Copy link

gllmhyt commented Oct 9, 2022

I would like to disable this feature on the instance I'm rocking, but I cannot seem to find where to hide the button asking for translation. Is it available or is it not yet implemented? When no API key for a translation service is given, the translate button should not be displayed (as it will fail/error every time).

@Tak
Copy link
Contributor

Tak commented Oct 9, 2022

This is also my motivation for wanting capability detection in the api

@SGombert
Copy link

SGombert commented Nov 14, 2022

There is another open-source software for self-hosting translation services called EasyNMT which supports many languages and uses more state-of-the-art techniques than LibreTranslate. https://github.com/UKPLab/EasyNMT Would it be possible also to support this backend? Unfortunately, I don't know Ruby so far, but Iooked at the code for the existing backends and it looks straightforward, so I will probably develop one for EasyNMT as soon as I find time.

@Vollans
Copy link

Vollans commented Nov 16, 2022

I've enabled the LibreTranslate version on my instance. A lot of foreign language posts either don't have a language set or are set as English, and so Translate isn't available. Is it possible to add a "Force Translate" to the "..." option?

@ineffyble
Copy link
Member

@Vollans Can you raise a feature request?

kadoshita pushed a commit to kadoshita/mastodon that referenced this pull request Nov 19, 2022
@JimKillock
Copy link

Did anyone think about allowing manual translations? (That is what I assumed “user translation” was when I read the feature, and to my mind would be very helpful for people writing / posting, as they may want multilingual content, but prefer to have accurate human translations).

@MasinAD
Copy link

MasinAD commented Dec 1, 2022

There is another open-source software for self-hosting translation services called EasyNMT which supports many languages and uses more state-of-the-art techniques than LibreTranslate. https://github.com/UKPLab/EasyNMT Would it be possible also to support this backend? Unfortunately, I don't know Ruby so far, but Iooked at the code for the existing backends and it looks straightforward, so I will probably develop one for EasyNMT as soon as I find time.

May I refer you to
grafik
(Source: Argos Translate )

@MasinAD
Copy link

MasinAD commented Dec 1, 2022

But I came here for something else: What's the best way to ask for support of translateLocally? Should I raise a feature request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api REST API, Streaming API, Web Push API NLnet Funded by NLnet, see https://nlnet.nl/project/Mastodon/ ui Front-end, design
Projects
None yet
Development

Successfully merging this pull request may close these issues.