通过JS判断浏览器语言后跳转到对应谷歌对应语言翻译

admin3年前javascript454

        <script>
        var lang = navigator.language || navigator.userLanguage;
        if(!/google|goog/i.test(window.location.href)) {
            if(lang == "es"){
                window.location.href = 'https://translate.google.com/translate?sl=auto&tl=es&u='+nowSiteUrl;
            }else if(lang == 'fr'){
                window.location.href = 'https://translate.google.com/translate?sl=auto&tl=fr&u='+nowSiteUrl;
            }else if(lang == 'de'){
                window.location.href = 'https://translate.google.com/translate?sl=auto&tl=de&u='+nowSiteUrl;
            }else if(lang == 'ru'){
                window.location.href = 'https://translate.google.com/translate?sl=auto&tl=ru&u='+nowSiteUrl;
            }else if(lang == 'da'){
                window.location.href = 'https://translate.google.com/translate?sl=auto&tl=da&u='+nowSiteUrl;
            }
        }
        </script>

相关文章

vuejs学习官网

https://cn.vuejs.org/...

Jquery ajax 同步阻塞引起的UI线程阻塞问题

这篇文章主要介绍了Jquery ajax 同步阻塞引起的UI线程阻塞问题的相关资料,需要的朋友可以参考下 最近做一个项...

paypal sandbox账号密码

sb-ix9iy15691932@business.example.com5fBKPo$Z...

如何使用PHP实现图片的无损压缩和优化

<?phpfunction compressImage($source, $destination, $maxWidth, $maxHeight, $quality) { $info...

js cookie函数

///设置cookie function setCookie(NameOfCookie, value, expiredays) {   ...

JS 异步编程方法:6种方案

https://www.runoob.com/js/js-promise.htmlhttps://blog.csdn.net/w17624003437/article/details/12587909...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。