我有一个网站,需要将网站从英语翻译成阿拉伯语。网站在.net中完成,一些常量数据正在使用资源文件进行翻译。来自数据库的动态数据需要使用google api进行翻译。使用代码here我可以翻译一个特殊的div。如何在同一页面上翻译多个不同的div。在一个页面上需要使用google api和资源文件翻译数据
答案 0 :(得分:0)
您可以使用下面的谷歌翻译api
使用JS
进行Google翻译示例 <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"> </script>
</head>
<body style="font-family: Arial; font-size: 12px;">
<div id="google_translate_element">
<input type="text" id="txtDetails" />
</div>
</body>
<script type="text/javascript" src="https://www.google.com/jsapi">
</script>
<script type="text/javascript">
// Load the Google Transliterate API
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
google.elements.transliteration.LanguageCode.KANNADA,
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
// Create an instance on TransliterationControl with the required
// options.
var control =
new google.elements.transliteration.TransliterationControl(options);
// Enable transliteration in the textbox with id
// 'transliterateTextarea'.
control.makeTransliteratable(['txtDetails']);
}
google.setOnLoadCallback(onLoad);
</script>
</html>
或使用下面的Microsoft Translator