我在我的網站上有兩個圖片,可以說英文和韓文。當用戶點擊韓國國旗並返回英國時,我希望我的網頁翻譯成韓語。指定特定語言在圖片上翻譯網站點擊
我想要一個JavaScript函數用於每個圖像的onclick事件,然後調用Google Translate API或Microsoft Translate API並返回翻譯後的頁面。
我不知道這是否可能,但如果是這樣,我會非常感激。雖然直接添加插件,但此時不適用於我。
謝謝...
我在我的網站上有兩個圖片,可以說英文和韓文。當用戶點擊韓國國旗並返回英國時,我希望我的網頁翻譯成韓語。指定特定語言在圖片上翻譯網站點擊
我想要一個JavaScript函數用於每個圖像的onclick事件,然後調用Google Translate API或Microsoft Translate API並返回翻譯後的頁面。
我不知道這是否可能,但如果是這樣,我會非常感激。雖然直接添加插件,但此時不適用於我。
謝謝...
挖硬後......我拿出來與冰的解決方案翻譯...
您可以發表評論的提醒等等。還有60000這裏指如果在60秒內沒有完成翻譯,則會顯示錯誤...
<!-- The image showing korean -->
<img id="Koebtn" src="images/SP2.jpg">
<!-- The Code to translate -->
<script src="http://www.microsoftTranslator.com/ajax/v3/WidgetV3.ashx?siteData=ueOIGRSKkd965FeEGM5JtQ**" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#Koebtn").click(function(){
if (document.readyState == 'complete') {
Microsoft.Translator.Widget.Translate('en', 'es', onProgress, onError, onComplete, onRestoreOriginal, 60000);
}
//You can use Microsoft.Translator.Widget.GetLanguagesForTranslate to map the language code with the language name
function onProgress(value) {
document.getElementById('counter').innerHTML = Math.round(value);
}
function onError(error) {
alert("Translation Error: " + error);
}
function onComplete() {
document.getElementById('counter').style.color = 'green';
}
//fires when the user clicks on the exit box of the floating widget
function onRestoreOriginal() {
alert("The page was reverted to the original language. This message is not part of the widget.");
}
});
});
</script>
我會喜歡類似的解決方案,但用谷歌翻譯API ......任何人的解決方案? – Josh
到目前爲止您做了什麼? – mehulmpt
我已經把bing翻譯小部件放在頁面上,但這不是真正的喜歡... – Josh