27

I'm using Google Translate tools to translate a web page and I also have an iframe on this page, that is not obviously translated with the page.

Is there a workaround, that any of you know, so I can have the iframe translated as well?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Jack Johnson
  • 593
  • 4
  • 11
  • 23

4 Answers4

11

This is a genuine limitation or policy of Google Translate. You can't rewrite iframe content. But one thing you can do is change iframe url to translated page like:

<iframe height="1200" width="600" src="http://translate.google.com/translate?hl=bg&ie=UTF-8&u=YOUR_IFRAME_URL&sl=de&tl=bg" align="middle" border="0">
alexisdevarennes
  • 5,437
  • 4
  • 24
  • 38
XIMRX
  • 2,130
  • 3
  • 29
  • 60
  • any other app in chrome store which translates the content in iframe ? or using some kind of proxy ? as i cannot change the url with in the iframe – forum.test17 Apr 27 '19 at 09:01
  • in fact you can if it's from the same domain – Flash Thunder Apr 27 '19 at 11:07
  • A couple of decades later in dog years and the Bing link no longer works. Is this a suitable substitute? https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator-text-api/ – Matt Thomas May 02 '19 at 12:24
1

If you need to translate the page with iframes, you can:

1. Use Bing Translator, that proxyfies request, so it wouldn't be cross domain.

site:

https://www.bing.com/translator

plugin that uses it (not tested):

https://chrome.google.com/webstore/detail/translator/blndkmebkmenignoajhoemebccmmfjib

2. You can run your browser (if it's Chrome) with --disable-web-security param, so it would allow access to frames from other domains.

Please note that it's dangerous and should only be used on trusted sites.

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
  • I cannot use bing translator, as i have login in to site which gets the information from another site and in an iframe, i have tried with proxy to change the url as suggested below, but it is not working :( – forum.test17 Apr 27 '19 at 10:38
  • Check the second solution then. There is no other effective way to force google translator to skip cross domain policy. – Flash Thunder Apr 27 '19 at 10:39
  • What do you get in console? any errors? if not, there has to be a precheck of origin, and there is no simple way to skip it. – Flash Thunder Apr 27 '19 at 11:05
  • i do not see any errors when trying to translate, only when I refresh the page as i have enabled the always translate mode. '[1:1:0427/131535:ERROR:render_media_log.cc(25)] MediaEvent: PIPELINE_ERROR demuxer: could not open ' – forum.test17 Apr 27 '19 at 11:17
  • Command for option 2 was: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --user-data-dir=./chrome --disable-web-security but did not work for me. – chiappa Jan 13 '21 at 02:30
  • The Google Translator code have totally changed. Now it translates chunks, only visible area. You would have to look for triggers and manually shoot them. That would probably require a custom browser extension. – Flash Thunder Jan 13 '21 at 13:24
1
  1. Create empty iframe.
  2. Ajax the second iframe content already translated by google translator.
  3. Dump the response of the ajax into empty iframe.

$("#id_of_empty_iframe").load("http://translate.google.com/translate?hl=bg&ie=UTF-8&u=YOUR_IFRAME_URL&sl=de&tl=bg");

Merak Marey
  • 749
  • 5
  • 15
-1

You could create a layer and put the translator code in it and put the layer top -500 so it hides the layer off the page with the Google dropdown selector in it.

shim
  • 9,289
  • 12
  • 69
  • 108
sh2605
  • 1