LemmyNet / lemmy-ui

The official web app for lemmy.
https://join-lemmy.org/
GNU Affero General Public License v3.0
886 stars 335 forks source link

Option to translate posts from different languages #1000

Open Nutomic opened 1 year ago

Nutomic commented 1 year ago

As posts and comments have language tags now, it should be relatively easy to translate them into another language which the user can understand. This would require some self-hosted translation tool which can be deployed alongside Lemmy.

There should also be a way for users to choose which languages or posts should be translated. This could be done with a user setting "translate languages", so posts in these languages are shown to the user and automatically translated. Alternatively it could be tied in with #999, so the user gets a button to show all comments for a given post, which can then be translated.

Getting this right will probably require some experimentation. It would be good to know if there are other websites which offer similar functionality, to see how they do it.

dessalines commented 1 year ago

I don't know about "in-place" translations, because that could be very complicated to implement. But there might be some services that can take text in its get params, and do something like:

https://translate.com/?to_language=de&text=....

SleeplessOne1917 commented 1 year ago

Maybe libretranslate could work? It's self-hostable and there's a docker image for it on dockerhub.

Nutomic commented 1 year ago

Based on my quick tests the translations arent that good. I noticed that Mastodon integrates deepl.com for translations, so thats also worth considering. Then we can still switch to a different tool later.

SleeplessOne1917 commented 1 year ago

DeepL is definitely higher quality. Having used the API for it before, an account can translate up to 500,000 characters per month for free before needing to pay.

Nutomic commented 1 year ago

In fact we can easily handle translations entirely on the backend and add an endpoint like GET /api/v3/post/translate?id=123&lang=es. Then instance admins could choose between different translation services, whether selfhosted or commercial. Then lemmy-ui mainly needs to provide an intuitive user interface for that.