Odd interaction with Discourse and Google Translate

This was brought up by one of regular members that uses a Firefox add-on for page translation, but this seems to be independent of it and can be reproduced with any page in meta.

Steps:

  1. go to https://translate.google.com/
  2. paste a URL like https://meta.discourse.org/t/using-discourse-index/308031
  3. hit the translate icon/button

You’ll likely land on a Discourse 404 page with a URL like this

https://meta-discourse-org.translate.goog/t/using-discourse-index/308031/t/using-discourse-index/308031?_x_tr_sl=en&_x_tr_tl=pt-PT&_x_tr_hl=en&_x_tr_pto=wapp&_x_tr_hist=true

Notice that the URL has the path /t/using-discourse-index/308031 duplicated in it. Removing the duplicate fragment makes the translation work as expected.

Normally this would be an issue with google translate, but it seems to only happen with Discourse (I’ve tried a few other websites) and after we updated to 3.2.

2 Likes

Sorry for rehashing this, but I think I chose the wrong title (and angle) and it didn’t get the proper attention.

Right now, Discourse is incompatible with Google Translate which is likely the most used translation tool.

Any topic URL pasted into Google Translate always ends up with the 404 page being translated and not the actual topic. It works ok with the homepage and topic lists URLs – but not a topic.

Perhaps Google Translate is being fed some special crawler/print version that doesn’t work for this purpose?

I use Google Translate regularly and I only saw this behaviour with Discourse topics, so at least part of the issue appears to be in Discourse.

It looks like this affects all Ember apps. For example, even Ember’s own documentation app

It looks like Google is proxying the site, injecting some Javascript, and injecting a <base> tag. We might be able to detect Google’s hacks and workaround the 404 issue… but I very much doubt any complex JS app like Discourse will work well through Google’s proxy.

A workaround is to use the translate functionality built in browsers (either native, or via an extension). Those do not have the same proxying/injecting behavior.

1 Like