Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2780952
  • 博文数量: 77
  • 博客积分: 10204
  • 博客等级: 上将
  • 技术积分: 5035
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-05 22:13
文章分类
文章存档

2013年(1)

2010年(1)

2009年(17)

2008年(58)

我的朋友

分类:

2008-08-08 14:06:13

<html>
    <head>
        <title></title>
        <script type="text/javascript" src=""></script>
        <script type="text/javascript">
            google.load("language", "1");
            function pageLangTrans(){
                if(! document.getElementById("text")) return false;
                if(! document.getElementById("translation")) return false;
                
                var readyToTrans = document.getElementById("text").innerHTML;
                
                google.language.detect(readyToTrans, function(transText) {
                    if(! transText.error && transText.language) {

                         //transText.language(自动探测) 将日本翻译为中文
                        google.language.translate(readyToTrans, transText.language, "zh-CN", function(transText){
                            var translated = document.getElementById("translation");
                            if(transText.translation) {
                                translated.innerHTML = transText.translation;
                            }
                        });
                    }
                });
            }
            google.setOnLoadCallback(pageLangTrans);
        </script>
    </head>
    <body>
        <div id="text">
            <table>
                <tr>
                    <td><span>チケット、</span></td>
                    <td><span>金券、</span></td>
                    <td><span>宿泊予約</span></td>
                </tr>
            </table>
        </div>
        <div id="translation"></div>
    </body>
</html>

阅读(1427) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~