zjffun blog

网页翻译

更新于 写于

Google

html
<!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 id="google_translate_element"></div>
    <script>
      function googleTranslateElementInit() {
        new google.translate.TranslateElement(
          {
            layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
            /*其他模式:google.translate.TranslateElement.InlineLayout.HORIZONTAL,
            google.translate.TranslateElement.InlineLayout.SIMPLE
            */
            //pageLanguage: 'en',//原文语言
            //includedLanguages: 'zh-CN'//翻译语言(可选,默认是全部语言)
          },
          "google_translate_element"
        );
      }
    </script>
    <script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
  </body>
</html>

Bing

html
<!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>