Google Website Translator Automatic Display Mode

前端 未结 8 1465
轮回少年
轮回少年 2020-12-20 14:37

I\'m trying to include google website translator on my website. I want to use the automatic thing so the bar shows up if your browser language is different to the page langu

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-20 15:06

    While trying to figure out why the autoDisplay was not functioning, i.e. the translate menu always displayed, I found the W3C Internationalization Checker: http://validator.w3.org/i18n-checker/

    The W3C Internationalization Checker alerted me that the Accept Headers were returning: Accept-Language: en-US,en;q=0.8

    The code generated by Google that I originally pasted into my site files only had one value to check the page language. But I edited it, see below, and passed an array into the pageLanguage key and I think it's now working.

    I ran tests as best I could by changing the language settings in Google Chrome. But I don't fully trust that it's working. The translate menu ought to appear for anyone without en or en-US configured in their browsers. You could pass in any language to the array to properly configure it for your needs.

    If anyone has any feedback on this I'd appreciate it. Hope it helps.

提交回复
热议问题