我有一个网站,在那里它需要将网站从英语翻译成阿拉伯语。网站是在.net中完成的,一些常量数据是使用资源文件转换的。其中,来自数据库的动态数据需要使用google api进行转换。使用代码here,我可以转换perticular div。如何在同一个page.On上翻译超过1个不同的div一页数据需要使用google api以及资源文件进行翻译
发布于 2014-02-03 17:47:04
你可以使用bellow for Google Translate 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使用bellow
Microsoft Translate
https://stackoverflow.com/questions/21523836
复制相似问题