如何使用google翻译使用geoip自动翻译网站
我一直在互联网上寻找一个脚本,该脚本将使用 google 翻译 api 通过 geoip 脚本自动翻译网站,而无需单击翻译按钮。由于谷歌确实提供了一个小的 div 片段,您可以将其添加到您的网站,然后通过下拉菜单您可以选择语言并单击翻译,它会翻译整个网站。
片段在这里 http://translate. google.com/translate_tools?hl=en&layout=1&eotf=1&sl=ru&tl=en
我如何将 geoip 脚本与上面的代码片段集成在一起,或者还有一些谷歌翻译互联网上提供的脚本。
I have been looking around the internet for a script which would use google translate api to translate a website automatically through a geoip script without the need of clicking translate button. Since google does provide a small div snippet which you can add to your website and then through a drop down menu you can choose the language and click translate and it translates the whole website.
the snippet is here
http://translate.google.com/translate_tools?hl=en&layout=1&eotf=1&sl=ru&tl=en
How can i integrate a geoip script along with the above snippet or there are also a couple of google translate scripts available on the internet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 geoip 来确定用户的语言并不是最佳方法,因为人们可能会说/喜欢与其地理位置上的主要语言不同的语言。
客户端发送的
Accept-Language
标头是您想要使用的内容,但它在 javascript 中不可用(至少以任何标准方式)。但是,有可用的
navigator.language
告诉我们浏览器 UI 的语言。尽管并不理想,但这很容易实现:Using geoip to determine user's language is not optimal way, because people may speak/prefer different language than the main language in their geographical location.
Accept-Language
header sent by client is something you would like to use, but it's not available in javascript (at least in any standard way).However, there's available
navigator.language
which tells us the language of browser UI. Though not ideal, this is very easy to implement: