Google Translate iframe workaround

前端 未结 4 636
礼貌的吻别
礼貌的吻别 2020-12-20 11:10

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 workarou

相关标签:
4条回答
  • 2020-12-20 11:44

    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">
    
    0 讨论(0)
  • 2020-12-20 11:46

    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.

    0 讨论(0)
  • 2020-12-20 11:51

    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.

    0 讨论(0)
  • 2020-12-20 11:57
    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");

    0 讨论(0)
提交回复
热议问题