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.