Google Translate iframe workaround
Asked Answered
I

4

28

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?

Idaidae answered 8/4, 2014 at 12:1 Comment(0)
L
12

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">
Liverpudlian answered 7/8, 2014 at 8:3 Comment(3)
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 iframeMiscount
in fact you can if it's from the same domainHeteroecious
A couple of decades later in dog years and the Bing link no longer works. Is this a suitable substitute? azure.microsoft.com/en-us/pricing/details/cognitive-services/…Beseem
H
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.

Heteroecious answered 27/4, 2019 at 9:23 Comment(6)
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 :(Miscount
Check the second solution then. There is no other effective way to force google translator to skip cross domain policy.Heteroecious
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.Heteroecious
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 'Miscount
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.Cynthea
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.Heteroecious
D
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");

Discontinuation answered 3/5, 2019 at 20:12 Comment(0)
A
-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.

Arithmomancy answered 15/12, 2019 at 2:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.