Discourse-Translator++

official
multi-lingual

(Alan Tan) #1

discourse-translator - GitHub - discourse/discourse-translator

Features++

  • Each post is only translated once per locale which saves you :moneybag:
  • Access Token is cached server side for faster translations.
  • Translations are rate limited to 3 per minute (Could be made configurable)

Translation Services Supported

Installation

Setup

Microsoft

Instructions
  1. Subscribe to the Microsoft Translator API on Azure. Basic subscriptions, up to 2 million characters a month, are free. Translating more than 2 million characters per month requires a payment. You may pick from any of the available subscription offers.

  2. Under Admin > Settings > Plugins, enter the subscription key that you’ve obtained from the steps above.

  1. Under Admin > Settings > Basic Setup, enable allow user locale.

Google Translator

Instructions
  1. Go to https://console.developers.google.com

  2. Click on My project

  3. Click on the :heavy_plus_sign: to create a new project

  4. Enter your project name and click create

  5. Select Enable API and search for Google Cloud Translator API. Look for the enable button and click it to enable the API. Note that there is no free tier for the Google Translator API so it may prompt you to enable billing.

  6. Once you’re done, click on credentials in the left menu

  7. Click create credentials and select API key. Copy the API Key and paste it into the translator google api key site setting.

Known Issues

  • Does not translate text within polls generated by discourse-poll plugin.
  • Images are enlarged upon translating.

TODOS

  • Allow admin to set quota and disable translation once quota has been exceeded.
  • Disable translation for private messages???

Advice for bilingual communities
Can we have have one post with two different language
Allow users to choose any interface language, supported or not
Plugin for signatures?
Inline translation of posts into another language
Include translated posts in search?
Translator plugin
Translate email notifications and digests into user preferred locale language
Translate email notifications and digests into user preferred locale language
Language Translation
Make a multi-language forum
How to handle users that don't really read the answers they get?
What exactly are the effects of "allow user locale"
Localized email templates
Google Translate shows "blank" page
Image zoom is not working
(Alan Tan) #2

Please help me to battle test it on your forums and feel free to complaint if it isn’t working as intended.


(Jeff Atwood) #3

Wow this is cool! We have a customer interested in this, so maybe we can move it to our GitHub tree in the next few weeks?


(Alan Tan) #4

Sure thing!

Do you think we need to identify the language of the posts before hand and hide the translate button if it matches the user’s or default locale? Twitter does that but it is pretty simple for them since they only have a maximum of 140 chars to translate. For us, it is going to impact performance somewhat since we will need to detect the language every time we create/edit a post.


(Sam Saffron) #5

If you can hide it, it is awesome


(Alan Tan) #6

:challengeaccepted: :challengeaccepted: :challengeaccepted: :challengeaccepted:


(Erlend Sogge Heggen) #7

Very cool. What happens if the original text is edited?


(Alan Tan) #8

We reset the custom fields that stores the detected lang and translated text


(Kane York) #9

Stick it in the Jobs::ProcessPost / CookedPostProcessor.


(Alan Tan) #11

Yea a background job is probably the better way :+1:


(Tobias Eigen) #12

I have installed this now on the Kabissa Forum and it works like a charm. Are there any issues that have come up for anybody so far? What’s the issue @tgxworld with the discourse-solved plugin?

Some initial feedback:

  • it takes a few seconds for the translation to appear, which is understandable. Some sort of progress indicator might be useful.
  • the topic title remains in the original language. if a post in a topic has been translated into the user’s locale, why not also display a translation of the title? Could be next to it or below it, perhaps in a smaller grey font?
  • do we have to indicate original language and credit microsoft? why not just display “translation:” in the user’s locale language?
  • I think “discourse inline translation” might be more suitable/clear as a name.

Update: here are some more thoughts after more clicking around - finding this to be working extremely well. Nicely done!

  • are there any privacy concerns with text being sent off site to microsoft and back again in another language? should we offer a user setting to allow/prevent translation of their posts in non-public categories? a site-wide setting for that? does that API call happen using an encrypted connection?

  • I can’t figure out how to specify the location on the post menu for the translate button. Right now on kabissa it’s second on the list.

  • if the translation is indeed permanently stored, should we allow it to be editable by trusted users? eg offer an “improve this translation” link based on admin settable trust level?

  • agreed with @sam above that displaying translations from english to english is silly. so display the translation button if possible only if the locale setting of author and logged in user is different.


(Tobias Eigen) #13

On Kabissa forum, translating a longish post into French resulted in an error - see below.

“Bad Request Bad Request - Request Too Long HTTP Error 400 - The size of the request headers is too long.”

Update: I have been continuing to click around and see that some other very long posts translate without problems. This particular one is basically a laundry list of discourse features so I suspect that the code in one of them is causing the translation to bork.


(Alan Tan) #14

Yea this is one scenario that the plugin needs to handle. There is a 10,000 chars limit by Microsoft Translation services.


(Alan Tan) #15

Opps my bad, I meant the polls plugin. Basically text within the polls is not translated for some reason. I’ll need to look into that.

:sweat_smile: I followed what Twitter is currently doing.

Those could be implemented though it’ll take awhile. Just pushed a fix to use a HTTPS to Microsoft’s API endpoint.

hehe because you can’t :stuck_out_tongue: I’ll place it on the TODO.

Yup something that can be done :smile:

<img src="//discourse-meta.s3-us-west-1.amazonaws.com/original/3X/2/d/2dc3a3b5bdf28b4b95fe779dd1959f69ad767a61.png" width=“477” height=“499”


Translate email notifications and digests into user preferred locale language
(Tobias Eigen) #16

You’re doing some great work here - very much appreciated. I have the latest version installed and it’s working very well.

I :heart: the progress indicator as it gets the translation!

I suspect twitter and bing have some sort of legal arrangement, and we might also be required to display this based on the translation service TOS. If not though I’d rather just display “Translation:”.

This is probably good enough for me - thanks! I suspect Microsoft and other translation services promise reasonable privacy, though would have to look at the TOS.

Cool! A link to simply “improve this translation” where twitter shows “wrong translation” link would be awesome! But perhaps for later if it proves to be complex.

But I’d orient the feature around “Improve this translation” language vs feedback which implies that someone else will be looking at it to approve the improvement.

This is a fairly big problem so unless you manage to fix it, please add this to the known issues! :smile:


(Kane York) #17

I suspect one of the two is getting :money_with_wings:


(Alan Tan) #18

I just made it awesome!


(Jesse Perry) #19

This all is amazing. Thank you so much for your work on this @tgxworld


(Tobias Eigen) #20

@tgxworld has this plugin now stabilized? Have you encountered any issues? I have been testing it out and it seems fine, so am considering installing it on my live site.


(Alan Tan) #21

There are a few UX bugs on my list but nothing major or breaking.