网站多语言切换插件

网站多语言切换插件

很多时候,可能我们web项目中需要的只是机械式的翻译,并不需要什么利用xml或者js json等等实现逼真翻译,那样工作量太大。这时候可能你就需要这几款小工具来帮助你。当然,如果对翻译或者你的项目外国用户非常多的话,还是介绍自己动手做语言切换,毕竟工具翻译是机械翻译

下面可以选择其中的一种放在你的网站进行多语言切换

1.谷歌翻译:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>TranslateTool</title>
</head>
<body>
    <div>Just do it.</div>
    <!--谷歌翻译-->
    <div ></div>
    <script>
        function googleTranslateElementInit() {
            new google.translate.TranslateElement({
                layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
            }, 'google_translate_element');
        }
    </script>
    <script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</body>
</html>

2. 微软翻译:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <div>Just do it.</div>
    <!--微软翻译-->
    <div  100%; min-height: 57px; border-color: #170D07;
        background-color: #362F2A;">
        <noscript>
            <a href="http://www.microsofttranslator.com/bv.aspx?a=http%3a%2f%2flocalhost%2f">
                Translate
                this page
            </a>
            <br />
            Powered by <a href="http://www.microsofttranslator.com">Microsoft® Translator</a>
        </noscript>
    </div>
    <script type="text/javascript">
        /* <![CDATA[ */setTimeout(function () {
            var s = document.createElement("script");
            s.type = "text/javascript";
            s.charset = "UTF-8";
            s.src = "http://www.microsofttranslator.com/Ajax/V2/Widget.aspx"
                + "?mode=auto"
                + "&from=en"
                + "&layout=ts"
                + "&appId=<%= InteractiveSDK.Properties.Settings.Default.WidgetAppId %>";
            var p = document.getElementsByTagName('head')[0] || document.documentElement; p.insertBefore(s, p.firstChild);
        }, 0);
        /* ]]> */
    </script>
</body>
</html>

3.必应翻译:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <div>Just do it.</div>
    <div>Just do it.</div>
    <div>Just do it.</div>
    <div>Just do it.</div>
    <div>Just do it.</div>
    <!--必应翻译-->
    <div id='MicrosoftTranslatorWidget' class='Dark' style='color:white;background-color:#555555'></div>
    <script type='text/javascript'>setTimeout(function () { { var s = document.createElement('script'); s.type = 'text/javascript'; s.charset = 'UTF-8'; s.src = ((location && location.href && location.href.indexOf('https') == 0) ? 'https://ssl.microsofttranslator.com' : 'http://www.microsofttranslator.com') + '/ajax/v3/WidgetV3.ashx?siteData=ueOIGRSKkd965FeEGM5JtQ**&ctf=True&ui=true&settings=Manual&from='; var p = document.getElementsByTagName('head')[0] || document.documentElement; p.insertBefore(s, p.firstChild); } }, 0);</script>
</body>
</html>