我有一个用英文创建的网页。根据大陆的不同,我想将我的整个网页动态翻译成另一种语言。
该网页相当复杂,因此我无法逐个字符串进行。我只是想以一种在加载时将其翻译成所需语言的方式进行操作。
我可以使用 Google Translate API 翻译我的网页吗?
我有一个用英文创建的网页。根据大陆的不同,我想将我的整个网页动态翻译成另一种语言。
该网页相当复杂,因此我无法逐个字符串进行。我只是想以一种在加载时将其翻译成所需语言的方式进行操作。
我可以使用 Google Translate API 翻译我的网页吗?
这是一个将谷歌翻译器添加到网页以翻译特定元素的示例:
<html>
<head>
<title>My Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="translate">Тестирование</p>
<div class="translate_control" lang="en"></div>
<script>
function googleSectionalElementInit() {
new google.translate.SectionalElement({
sectionalNodeClassName: 'translate',
controlNodeClassName: 'translate_control',
background: '#f4fa58'
}, 'google_sectional_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>
</body>
</html>
您可以在页面上添加一个 Google 翻译小部件,用户可以根据需要翻译成他们选择的语言。http://www.google.com/webelements/#!/translate
是的你可以。在此处查看 Google 翻译 API 文档:http ://code.google.com/apis/language/translate/v2/getting_started.html
请注意,截至 2011 年,自动机器翻译还不足以与人工翻译相匹配,因此不要指望翻译后的文本会是完美的——它可能通过努力就可以理解,但很明显它是机器翻译的.
可能你可以使用微软翻译 API。你可以在 http://code.google.com/p/micrsoft-translator-php-wrapper/找到实现,你也可以在http://renjith.co 看到演示 。在/翻译/