How to add Google Translate link that triggers translation?

后端 未结 2 727
礼貌的吻别
礼貌的吻别 2021-01-02 21:57

I have a web page in Bulgarian and I want my users be able to translate it one-click to English. Also there should not be any translation banner at the top of the page when

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 22:31

    Google has thought ahead my friend. Please look at this page: http://translate.google.com/translate_tools

    EDIT: I'm sorry, I just realized you're using what the page provides! You can, with simple javascript, hide the elements that are displayed and create a link for English where it's onClick changes the value of the hidden select element...and your entire page is translated.

    It's a bit messy but it gets the job done and the user doesn't know it exists!

    You can also consider capturing the request that is sent to the google translate servers and capture the link that is called when you select English and just use that link.

    Chrome has a nice utility to capture requests (see ctrl+shift+j for a developer console)

提交回复
热议问题