Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Translate on Javascript-generated content
    primarykey
    data
    text
    <p>Is there any way to translate content that is generated from user form input when using Google Translate (using the method I employ below)?</p> <p>Right now, the page will translate, but when a user fills in and submits the form on a translated page, the answer, of course, is returned in English. This makes sense, since the translation takes place prior to the form submission (and takes place on Google's servers). </p> <p>Is there any relatively simple way around that? I'm still feeling my way around javascript, so any details you can provide are much appreciated. Just thinking about this made my tiny head explode.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script type="text/javascript"&gt; &lt;!-- 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 &gt; 31){ alert("Come now, no month has " + one + " days! Please try again."); } else if(selection == "z4"){ var prodZ4 = z4yearlyCash - 1680; if(prodZ4 &gt; 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Yearly Savings&lt;\/h3&gt;&lt;p&gt;If you pay cash, your yearly expense is $" + z4yearlyCash + ".&lt;br&gt;Commuter Express Zone 4 Monthly Passes cost $1680 per year.&lt;br&gt;&lt;strong&gt;That&amp;#39;s a yearly savings of $" + prodZ4 + "!&lt;\/strong&gt;&lt;br&gt;&lt;strong&gt;&lt;a href='http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=CTGY&amp;amp;Store_Code=LTSO&amp;amp;Category_Code=MP4'&gt;Buy a Commuter Express Zone 4 Monthly Pass now.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } else if(prodZ4 &lt;= 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Results&lt;\/h3&gt;&lt;p&gt;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. &lt;strong&gt;&lt;a href='#triptickets'&gt;Try the Trip Tickets Calculator below.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } } else if(selection == "z3"){ var prodZ3 = z3yearlyCash - 1488; if(prodZ3 &gt; 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Yearly Savings&lt;\/h3&gt;&lt;p&gt;If you pay cash, your yearly expense is $" + z3yearlyCash + ".&lt;br&gt;Commuter Express Zone 3 Monthly Passes cost $1488 per year.&lt;br&gt;&lt;strong&gt;That&amp;#39;s a yearly savings of $" + prodZ3 + "!&lt;\/strong&gt;&lt;br&gt;&lt;strong&gt;&lt;a href='http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&amp;Store_Code=LTSO&amp;Product_Code=LADOTMPZ3&amp;Category_Code=MP4'&gt;Buy A Commuter Express Zone 3 Monthly Pass Now&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } else if(prodZ3 &lt;= 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Results&lt;\/h3&gt;&lt;p&gt;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. &lt;strong&gt;&lt;a href='#triptickets'&gt;Try the Trip Tickets Calculator below.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } } else if(selection == "z2"){ var prodZ2 = z2yearlyCash - 1200; if(prodZ2 &gt; 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Yearly Savings&lt;\/h3&gt;&lt;p&gt;If you pay cash, your yearly expense is $" + z2yearlyCash + ".&lt;br&gt;Commuter Express Zone 2 Monthly Passes cost $1200 per year.&lt;br&gt;&lt;strong&gt;That&amp;#39;s a a yearly savings of $" + prodZ2 + "&lt;\/strong&gt;!&lt;br&gt;&lt;strong&gt;&lt;a href='http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&amp;Store_Code=LTSO&amp;Product_Code=LADOTMPZ2&amp;Category_Code=MP4'&gt;Buy A Commuter Express Zone 2 Monthly Pass Now&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } else if(prodZ2 &lt;= 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Results&lt;\/h3&gt;&lt;p&gt;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. &lt;strong&gt;&lt;a href='#triptickets'&gt;Try the Trip Tickets Calculator below.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } } else if(selection == "z1"){ var prodZ1 = z1yearlyCash - 960; if(prodZ1 &gt; 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Yearly Savings&lt;\/h3&gt;&lt;p&gt;If you pay cash, your yearly expense is $" + z1yearlyCash + ".&lt;Br&gt;Commuter Express Zone 1 Monthly Passes cost $960 per year.&lt;br&gt;&lt;strong&gt;That&amp;#39;s a yearly savings of $" + prodZ1 + "&lt;\/strong&gt;!&lt;br&gt;&lt;strong&gt;&lt;a href='http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&amp;Store_Code=LTSO&amp;Product_Code=LADOTMPZ1&amp;Category_Code=MP4'&gt;Buy A Commuter Express Zone 1 Monthly Pass Now&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } else if(prodZ1 &lt;= 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Results&lt;\/h3&gt;&lt;p&gt;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. &lt;strong&gt;&lt;a href='#triptickets'&gt;Try the Trip Tickets Calculator below.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } } else if(selection == "Base"){ var prodBase = baseyearlyCash - 684; if(prodBase &gt; 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Yearly Savings&lt;\/h3&gt;&lt;p&gt;If you pay cash, your yearly expense is $" + baseyearlyCash + ".&lt;br&gt;Commuter Express Base Monthly Passes cost $684 per year.&lt;br&gt;&lt;strong&gt;That&amp;#39;s a yearly savings of $" + prodBase + "!&lt;\/strong&gt;&lt;br&gt;&lt;strong&gt;&lt;a href='http://store.ladottransit.com/Merchant2/merchant.mvc?Screen=PROD&amp;Store_Code=LTSO&amp;Product_Code=LADOTMPB&amp;Category_Code=MP4'&gt;Buy A Commuter Express Base Monthly Pass Now&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } else if(prodBase &lt;= 0){ answerCemp.innerHTML="&lt;div class='answerbox'&gt;&lt;h3&gt;Your Results&lt;\/h3&gt;&lt;p&gt;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. &lt;strong&gt;&lt;a href='#triptickets'&gt;Try the Trip Tickets Calculator below.&lt;\/a&gt;&lt;\/strong&gt;&lt;\/p&gt;&lt;\/div&gt;"; } } } // End CE MP Savings Calc script --&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="javascript:window.location = 'http://translate.google.com/translate?hl=en&amp;amp;sl=en&amp;amp;tl=' + document.translateform.translate.value + '&amp;amp;u=' + window.location.href;" method="get" name="translateform"&gt; &lt;label for="translate"&gt;translate this page&lt;/label&gt; &lt;select name="translate" id="translate"&gt; &lt;option value="es"&gt;Spanish&lt;/option&gt; &lt;option value="ar"&gt;Arabic&lt;/option&gt; &lt;option value="zh-CN"&gt;Chinese Simplified&lt;/option&gt; &lt;option value="zh-TW"&gt;Chinese Traditional&lt;/option&gt; &lt;option value="nl"&gt;Dutch&lt;/option&gt; &lt;option value="fr"&gt;French&lt;/option&gt; &lt;option value="de"&gt;German&lt;/option&gt; &lt;option value="el"&gt;Greek&lt;/option&gt; &lt;option value="it"&gt;Italian&lt;/option&gt; &lt;option value="ja"&gt;Japanese&lt;/option&gt; &lt;option value="ko"&gt;Korean&lt;/option&gt; &lt;option value="pt"&gt;Portuguese&lt;/option&gt; &lt;option value="ru"&gt;Russian&lt;/option&gt; &lt;/select&gt; &lt;div class="gobuttonwrapper"&gt; &lt;input name="submit" type="submit" value="go" class="gobutton"&gt; &lt;/div&gt; &lt;/form&gt; &lt;div class="calcform"&gt; &lt;form name="theForm3"&gt; &lt;h2&gt;&lt;a name="cemp" id="cemp"&gt;&lt;/a&gt;You Do the Math: Commuter Express Monthly Pass Vs. Cash&lt;/h2&gt; &lt;div class="calcform-content"&gt; &lt;div class="formrow-calc"&gt; &lt;div class="calcform-col1"&gt; &lt;label for="trips-cemp"&gt;Daily boardings on Commuter Express Bus*:&lt;/label&gt; &lt;input type="text" id="trips-cemp"&gt; &lt;/div&gt;&lt;div class="calcform-col3"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="formrow-calc"&gt; &lt;div class="calcform-col1"&gt; &lt;label for="days-cemp"&gt;Days you ride Commuter Express &lt;strong&gt;per month&lt;/strong&gt;:&lt;/label&gt; &lt;input type="text" id="days-cemp"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="formrow-calc"&gt; &lt;div class="calcform-col1"&gt; &lt;label for="choosezone"&gt;Choose Zone:&lt;/label&gt; &lt;select name="zone" id="choosezone"&gt; &lt;option value="Base"&gt;Base&lt;/option&gt; &lt;option value="z1"&gt;Zone 1&lt;/option&gt; &lt;option value="z2"&gt;Zone 2&lt;/option&gt; &lt;option value="z3"&gt;Zone 3&lt;/option&gt; &lt;option value="z4"&gt;Zone 4&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;div align="center"&gt; &lt;button type="submit" onclick="doMath3(); return false;" class="btn-submit"&gt;&lt;img src="img/btn_savings.png" alt="Show My Yearly Savings"&gt;&lt;br&gt; &lt;img src="img/arrow_results.png" alt="your results will display below"&gt;&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;div id="answerCemp"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload