使用必应翻译 API 翻译完整的网页

translating complete web page with bing tranlation API

本文关键字:翻译 网页 API      更新时间:2023-09-26

我正在尝试使用必应API而不是必应小部件翻译完整的网页,因为我想为翻译面板进行自定义设计,但我找不到任何方法,我在Azure市场注册并获得了密钥,所有示例都是为翻译文本框文本而制作的...任何人都可以为我提供一些帮助吗?

找到后,必须用这个java脚本来翻译网页,

            <script src="http://www.microsoftTranslator.com/ajax/v3/WidgetV3.ashx?siteData=ueOIGRSKkd965FeEGM5JtQ**" type="text/javascript"></script>
       <script type="text/javascript">
                   function translate(co) {
                      if (document.readyState == 'complete') {
                          Microsoft.Translator.Widget.Translate('en', co, onComplete);

                      }
                  }
                  function onComplete() {
                      Microsoft.Translator.Widget.domTranslator.showTooltips = false;
                      Microsoft.Translator.Widget.domTranslator.showHighlight = false;
                      Microsoft.Translator.Widget.domTranslator.showmessagebox = false;
                      Microsoft.Translator.Widget.showTooltips = false;
                  }
                  //You can use Microsoft.Translator.Widget.GetLanguagesForTranslate to map the language code with the language name

只需在任何点击中发送语言代码,例如:

        <a href="#" id="a1" style="list-style-image: url('images/flags/ac.png');" lang="en" class="selected">English</a>

希望您能发现这很有用。