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

LibreTranslate provider support #36

Merged
merged 8 commits into from
Dec 13, 2023
Merged

Conversation

pierotofy
Copy link
Contributor

Hello βœ‹ !

This PR adds support for libretranslate (https://libretranslate.com) as a translation provider.

image

Hope this can be useful to others. Let me know if changes are needed.

Cheers! πŸ₯‚

@pierotofy
Copy link
Contributor Author

Anyone home? πŸ‘‹

@danir-de
Copy link

danir-de commented Mar 14, 2022

@discourse What happened here?

@sunjam
Copy link

sunjam commented May 20, 2022

@pierotofy try asking on https://meta.discourse.org/t/discourse-translator/32630 ❀️

Their meta forum is where all discussion happens.

@gdevenyi
Copy link

@pierotofy try asking on meta.discourse.org/t/discourse-translator/32630 heart

Same radio silence on the meta discourse as here, will this ever be merged?

@pierotofy
Copy link
Contributor Author

I recommend people just use our fork at https://github.com/LibreTranslate/discourse-translator

@gdevenyi
Copy link

I've forked the original repo and merged the plugin into an upated branch here, https://github.com/gdevenyi/discourse-translator/tree/deploy

@CvX CvX requested a review from pmusaraj June 7, 2022 10:03
Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pierotofy, many apologies, we didn't see this earlier. It looks good, though, thank you!

Any chance you can grant Discourse (and send privately) an API key for testing? We don't run our own LibreTranslate instance and currently don't have the time to stand one up.

@tgxworld
Copy link
Contributor

tgxworld commented Jun 8, 2022

If anyone can write tests for this PR, we'll be happy to review and merge this.

@pierotofy
Copy link
Contributor Author

You can use one of the open mirrors here to test this without needing an API key: https://github.com/LibreTranslate/LibreTranslate#mirrors

I've also updated the fork at https://github.com/LibreTranslate/discourse-translator with the latest changes for those that can't wait for this to be merged.

@bdecotte
Copy link

Hi @pierotofy , it seems SUPPORTED_LANG
https://github.com/LibreTranslate/discourse-translator/blob/c2067a2512ec942106ee81e57625d326ea334965/services/discourse_translator/libretranslate.rb#L10
has become SUPPORTED_LANG_MAPPING

detected_lang != "DiscourseTranslator::#{SiteSetting.translator}::SUPPORTED_LANG_MAPPING".constantize[I18n.locale]

and the /languages url needs the GET method
https://github.com/LibreTranslate/discourse-translator/blob/c2067a2512ec942106ee81e57625d326ea334965/services/discourse_translator/libretranslate.rb#L81

@poVoq
Copy link

poVoq commented Sep 28, 2022

https://meta.discourse.org/t/discourse-translator/32630

claims Libre-translate is supported, but this isn't merged yet?

@pmusaraj
Copy link
Contributor

Yes, that is correct. The meta topic points to the fork that has LibreTranslate support.

This PR needs a refactor before merging, see the comment by @bdecotte just above.

@satoshinotdead
Copy link

So, we are OK now? :)

@johnsonm
Copy link

johnsonm commented Jul 14, 2023

@pmusaraj I note that the latest version has SUPPORTED_LANG_MAPPING now and it now has the GET method added.

Is there anything else in the way of merging this? (Well, other than there was no response when it was fixed and now there are conflicts...)

@pmusaraj
Copy link
Contributor

Apologies for the very long delay here, all... but this is now approved and I am merging it. Thanks for all your work here!

I tested the feature locally using these steps:

pip3 install libretranslate # installs LibreTranslate

libtranslate # starts the service and on the first run it downloads dictionaries
ltmanage keys add 120 # adds an api key for use in the site settings

libtranslate --api-keys # optional, for testing the api key in the LibreTranslate UI

@pmusaraj pmusaraj merged commit 86dd9ce into discourse:main Dec 13, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.