Google翻译Javascript生成的内容

如何解决Google翻译Javascript生成的内容

| 使用Google Translate(使用我在下面采用的方法)时,是否有任何方法可以翻译从用户表单输入生成的内容? 现在,页面将进行翻译,但是当用户填写并在翻译后的页面上提交表格后,答案当然会以英语返回。这是有道理的,因为翻译是在表单提交之前进行的(并且在Google的服务器上进行)。 有什么相对简单的方法可以解决吗?我仍然对JavaScript感到陌生,因此非常感谢您提供的任何详细信息。一想到这,我的小脑袋就会爆炸。
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Untitled Document</title>

    <script type=\"text/javascript\">

   <!-- Begin CE MP Savings Calc script
    function  doMath3() {
        var one = parseInt(document.theForm3.elements[0].value);
        var two = parseInt(document.theForm3.elements[1].value);
        var three = one * two;
        var z4yearlyCash = three * 4.25 * 12;
        var z3yearlyCash = three * 3.75 * 12;
        var z2yearlyCash = three * 3 * 12;
        var z1yearlyCash = three * 2.5 * 12;
        var baseyearlyCash = three * 1.5 * 12;
        var selection = document.getElementsByName(\"zone\")[0].value;
        var answerCemp = document.getElementById(\"answerCemp\");


    if (document.theForm3.elements[0].value == \"\"){
    alert(\"Please enter the number of days a month you commute on Commuter Express.\")   
    }

    if (document.theForm3.elements[1].value == \"\"){
    alert(\"Please enter the number of times you board a Commuter Express daily.\")   
    }   
        if(one > 31){
            alert(\"Come now,no month has \" + one + \" days! Please try again.\");
        }

        else if(selection == \"z4\"){
            var prodZ4 = z4yearlyCash - 1680;
        if(prodZ4 > 0){
           answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash,your yearly expense is $\" + z4yearlyCash + \".<br>Commuter Express Zone 4 Monthly Passes cost $1680 per year.<br><strong>That&#39;s a yearly savings of $\"  +  prodZ4  +  \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=CTGY&amp;Store_Code=LTSO&amp;Category_Code=MP4\'>Buy a Commuter Express Zone 4 Monthly Pass now.<\\/a><\\/strong><\\/p><\\/div>\";
            }
        else if(prodZ4 <= 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
        }
        }

        else if(selection == \"z3\"){
            var prodZ3 = z3yearlyCash - 1488;
            if(prodZ3 > 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash,your yearly expense is $\" + z3yearlyCash + \".<br>Commuter Express Zone 3 Monthly Passes cost $1488 per year.<br><strong>That&#39;s a yearly savings of $\"  +  prodZ3  +  \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ3&Category_Code=MP4\'>Buy A Commuter Express Zone 3 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
            }
            else if(prodZ3 <= 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
        }
        }

        else if(selection == \"z2\"){
            var prodZ2 = z2yearlyCash - 1200;
            if(prodZ2 > 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash,your yearly expense is $\" + z2yearlyCash + \".<br>Commuter Express Zone 2 Monthly Passes cost $1200 per year.<br><strong>That&#39;s a a yearly savings of $\"  +  prodZ2  +  \"<\\/strong>!<br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ2&Category_Code=MP4\'>Buy A Commuter Express Zone 2 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
            }
            else if(prodZ2 <= 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
        }       
        }

        else if(selection == \"z1\"){
            var prodZ1 = z1yearlyCash - 960;
            if(prodZ1 > 0){
             answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash,your yearly expense is $\" + z1yearlyCash + \".<Br>Commuter Express Zone 1 Monthly Passes cost $960 per year.<br><strong>That&#39;s a yearly savings of $\"  +  prodZ1  +  \"<\\/strong>!<br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPZ1&Category_Code=MP4\'>Buy A Commuter Express Zone 1 Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
            }
            else if(prodZ1 <= 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
        }
        }

        else if(selection == \"Base\"){
            var prodBase = baseyearlyCash - 684;
            if(prodBase > 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Yearly Savings<\\/h3><p>If you pay cash,your yearly expense is $\" + baseyearlyCash + \".<br>Commuter Express Base Monthly Passes cost $684 per year.<br><strong>That&#39;s a yearly savings of $\"  +  prodBase  +  \"!<\\/strong><br><strong><a href=\'http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&Store_Code=LTSO&Product_Code=LADOTMPB&Category_Code=MP4\'>Buy A Commuter Express Base Monthly Pass Now<\\/a><\\/strong><\\/p><\\/div>\";
            }
            else if(prodBase <= 0){
            answerCemp.innerHTML=\"<div class=\'answerbox\'><h3>Your Results<\\/h3><p>Looks like you don\'t ride Commuter Express often enough to benefit from purchasing a Monthly Pass. Trip Tickets may be a better option for you. <strong><a href=\'#triptickets\'>Try the Trip Tickets Calculator below.<\\/a><\\/strong><\\/p><\\/div>\";
        }
        }
    }

    // End CE MP Savings Calc script -->

    </script>

</head>

<body>

<form action=\"javascript:window.location = \'http://translate.google.com/translate?hl=en&amp;sl=en&amp;tl=\' + document.translateform.translate.value + \'&amp;u=\' + window.location.href;\" method=\"get\" name=\"translateform\">
                    <label for=\"translate\">translate this page</label>
                    <select name=\"translate\" id=\"translate\">
                      <option value=\"es\">Spanish</option>
                      <option value=\"ar\">Arabic</option>
                      <option value=\"zh-CN\">Chinese Simplified</option>
                      <option value=\"zh-TW\">Chinese Traditional</option>
                      <option value=\"nl\">Dutch</option>
                      <option value=\"fr\">French</option>
                      <option value=\"de\">German</option>
                      <option value=\"el\">Greek</option>
                      <option value=\"it\">Italian</option>
                      <option value=\"ja\">Japanese</option>
                      <option value=\"ko\">Korean</option>
                      <option value=\"pt\">Portuguese</option>
                      <option value=\"ru\">Russian</option>
                    </select>
                    <div class=\"gobuttonwrapper\">
                      <input name=\"submit\" type=\"submit\" value=\"go\" class=\"gobutton\">
                    </div>
                  </form>


<div class=\"calcform\">
  <form name=\"theForm3\">
<h2><a name=\"cemp\" id=\"cemp\"></a>You Do the Math: Commuter Express Monthly Pass Vs. Cash</h2>
                        <div class=\"calcform-content\">
                          <div class=\"formrow-calc\">
                            <div class=\"calcform-col1\">
                              <label for=\"trips-cemp\">Daily boardings on Commuter Express Bus*:</label>
                              <input type=\"text\" id=\"trips-cemp\">

                            </div><div class=\"calcform-col3\"></div>
                          </div>
                          <div class=\"formrow-calc\">
                            <div class=\"calcform-col1\">
                              <label for=\"days-cemp\">Days you ride Commuter Express <strong>per month</strong>:</label>

                            <input type=\"text\" id=\"days-cemp\"></div>


                          </div>
                          <div class=\"formrow-calc\">
                            <div class=\"calcform-col1\">
                              <label for=\"choosezone\">Choose Zone:</label>
                              <select name=\"zone\" id=\"choosezone\">
                                <option value=\"Base\">Base</option>
                                <option value=\"z1\">Zone 1</option>
                                <option value=\"z2\">Zone 2</option>
                                <option value=\"z3\">Zone 3</option>
                                <option value=\"z4\">Zone 4</option>
                              </select>

                            </div>
                          </div>
                          <div class=\"clear\"></div>
                          <div align=\"center\">
                            <button type=\"submit\" onclick=\"doMath3(); return false;\" class=\"btn-submit\"><img src=\"img/btn_savings.png\" alt=\"Show My Yearly Savings\"><br>
                            <img src=\"img/arrow_results.png\" alt=\"your results will display below\"></button>
                          </div>


                        </div>
                      </form>
                      <div id=\"answerCemp\"></div>
                    </div>

</body>
</html>
    

解决方法

        如果您自己创建页面,尤其是要翻译页面的各个元素的位置,则可以使用此插件。要填充翻译数据,您可以使用Google翻译获取文本短语的翻译版本。 https://github.com/coolbloke1324/jquery-lang-js 该插件具有跨页面的语言持久性,允许基于短语和基于正则表达式的匹配,可以处理任意数量的语言选项,并允许您根据所描述的click事件触发更改。 您可以在https://www.orbzu.com上看到它的实时使用情况(在页面的左上方查找标记图标,然后选择一种新的语言以查看页面上的文本自动更改)。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-