问题
I'm trying to translate complete webpage using Bing API instead of Bing widget , because I want to make custom design for translation panel , but I cant find any way , I registered in Azure market place and got Key , all samples are made for translating a textbox text ... could any one please provide me some help ?
回答1:
Found , you must this java script to translate webpage ,
<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
Just send language code in any onclick , for example :
<a href="#" id="a1" style="list-style-image: url('images/flags/ac.png');" lang="en" class="selected">English</a>
hope you can find this useful.
来源:https://stackoverflow.com/questions/26990932/translating-complete-web-page-with-bing-tranlation-api