Translate plugin installed, but no translate button

I’ve:

  • Installed the plugin.
  • Ticked “Allow inline translation of posts”.
  • Followed the steps to get a Microsoft key.
  • Selected Microsoft as my translator and added the key.
  • Created a topic in a foreign language.

But I don’t see any translation (globe) button next to the link button as depicted in the plugin instructions.

I’ve also tried uninstalling and reinstalling the plugin. And this is the only plugin I’ve added now.

Should I see that button no matter what?

Should I test the Microsoft API somehow?

Are there any troubleshooting steps for this plugin?

Thanks!




2 Likes

Sorry about the lack of replies for the issue with the translate button not appearing. The difficulty with answering your question is that someone will need to go through the steps to configure the plugin to use the MIcrosoft translation service. If we can’t find anyone who is using Microsoft Translator with the plugin, I’ll look into what I can do to set that up next week.

I’m going to move your topic to the #plugin:translator category to see if that will help it to get noticed.

3 Likes

Thanks for replying. Wouldn’t a broken Translation button still appear if the problem were possibly with Microsoft failing? I would be glad to troubleshoot the Microsoft Translation API, but I didn’t see documentation for that. Thanks again.

The translate button will only show if we detect that the language of the post is different from the current locale which that user has selected.

You can test it by running the following commands

./launcher enter app
rails c
=> DiscourseTranslator::Microsoft.detect(Post.last)

An error will be raised if the subscription key has not been configured correctly.

3 Likes

Thanks for your reply. The translator is now working. Details of how I got to a solution follow, in case this information is valuable to anyone.

Also, when I asked “should I see that button no matter what”, my intended question was more “whether the API key is working or not”, not “even if my preferred language is already used”. It appears the answer is that the translate button hides itself if the API fails.

When I SSHed into our machine, ran cd /var/discourse/, then ./launcher enter app, then rails c, then DiscourseTranslator::Microsoft.detect(Post.last), the output was:

DiscourseTranslator::TranslatorError: : 
from /var/www/discourse/plugins/discourse-translator/services/discourse_translator/microsoft.rb:70:in `access_token'

So then I ran this test per Microsoft Docs:

// Pass secret key and region using headers
curl -X POST "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es" \
     -H "Ocp-Apim-Subscription-Key:<your-key>" \
     -H "Ocp-Apim-Subscription-Region:<your-region>" \
     -H "Content-Type: application/json" \
     -d "[{'Text':'Hello, what is your name?'}]"

The output indicated success:

[{"detectedLanguage":{"language":"en","score":1.0},"translations":[{"text":"Hola, ¿cómo te llamas?","to":"es"}]}]%                                            ~ % 

I noticed the region was included in the curl command, but not in the Discourse plugin. I’m in California, but my users will be global and mostly in Western Europe. I recalled Microsoft’s process for instantiating their Translator required I choose a region, and it recommended westeurope for general usage by North American and Western European Users.

I attempted to change it to global now, but couldn’t find a way to do so. So I created a new resource, and it let me choose global today. And now with this new key, it works.

Thanks for your help.

7 Likes

Thank you for this solution!

2 Likes