Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Google Language and Dynamic URLS

  1. #1
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Google Language and Dynamic URLS

    One of the greatest things about the internet is the international audience. One the weakest links is the adoption of language translation. So I set out to fix this for one of my websites.

    I was able to modify the translate website frame on Google to place this into a website. I was able to remove the text field by manually entering the url inside the code. The result is nothing more then a drop down list with a submit button. Very clean and easy to use. It is an on-page "complete" Google Translate tool! Upon clicking submit it works.

    However, I don't want to have to change this on every page if I can avoid it. Is there a javascript that can enter the current page url into the value of a form tag? from what I can tell it must go into the exact feild that has <input type="hidden" name="u" value="INSERT URL HERE" />

    Thanks for your help if you can!!!!!

    Disclaimer: I do not know any java, so assume I know nothing about where to place the parts. can you provide a complete code solution? I am trying to be xhtml valid, thanks!

    Here is the code: please fell free to do with it what you want

    <!--begin translation, insert into body where you want it to show -->

    <table width="100%" cellpadding="3" cellspacing="0" border="0" align="left">
    <tr bgcolor="#ffffff">
    <td>
    <form name="translateForm" target="_translate" action="http://www.google.com/translate?u=" method="get">
    <table>
    <tr bgcolor="#ffffff">
    <td><form name="translateForm" form action="http://www.google.com/translate?" >
    <input type="hidden" name="u" value="INSERT URL HERE" />
    <select name="langpair">
    <option value="en|de" selected="selected">English to German</option>
    <option value="en|es">English to Spanish</option>
    <option value="en|fr">English to French</option>
    <option value="en|it">English to Italian</option>
    <option value="en|pt">English to Portuguese</option>
    <option value="en|ar">English to Arabic</option>
    <option value="en|ja">English to Japanese</option>
    <option value="en|ko">English to Korean</option>
    <option value="en|zh-CN">English to Chinese&nbsp;(Simple)</option>
    <option value="de|en">German to English</option>
    <option value="de|fr">German to French</option>
    <option value="es|en">Spanish to English</option>
    <option value="fr|en">French to English</option>
    <option value="fr|de">French to German</option>
    <option value="it|en">Italian to English</option>
    <option value="pt|en">Portuguese to English</option>
    <option value="ar|en">Arabic to English/option>
    <option value="ja|en">Japanese to English</option>
    <option value="ko|en">Korean to English</option>
    <option value="zh-CN|en">Chinese&nbsp;(Simple) to English</option>
    </select>
    <input type="hidden" name="hl" value="en" />
    <input type="hidden" name="ie" value="UTF8" />
    <br />
    <input type="submit" value="Translate" />
    </form>
    </td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>

    <!-- end translation-->

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    I am trying to be xhtml valid, thanks!
    Remove that outer form, then. I'm sure nested forms aren't valid.
    Code:
    <form name="translateForm" form action="http://www.google.com/translate" onsubmit="this.elements.u.value = window.location.href;">
    Remember, though, that this is a temporary measure until you can change each page individually. It is a nowhere near as good a solution, since it requires scripting support.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey,

    I knew this would be simple but I have to tell you that what I little code there was took me about 23 hours to get figured out.

    I come from a WYSIWYG user side world. This has been one of the most educational and frustrating ideas of my life.

    Thanks for your help!

    Mark

  4. #4
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is it possible to simplify this by removing the submit button and simply making it a onselect event?

    This is what I have now.. Thanks again for your wonderful help! - Mark

    <table align="left">
    <form name="translateForm" form action="http://www.google.com/translate" onsubmit="this.elements.u.value = window.location.href;">
    <input type="hidden" name="u" value="" />
    <select name="langpair">
    <option value="" selected="selected">Translate</option>
    <option value="en|it">Italian</option>
    <option value="en|de">German</option>
    <option value="en|es">Spanish</option>
    <option value="en|fr">French</option>
    <option value="en|pt">Portuguese</option>
    <option value="en|ar">Arabic</option>
    <option value="en|ja">Japanese</option>
    <option value="en|ko">Korean</option>
    <option value="en|zh-CN">Chinese (S)</option>
    </select>
    <input type="hidden" name="hl" value="en" />
    <input type="hidden" name="ie" value="UTF8" />
    <br />
    <input type="submit" value="Translate" />
    </form>
    </table>

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <table align="left">
    <form name="translateForm" action="http://www.google.com/translate" onsubmit="this.elements.u.value = window.location.href;">
    <input type="hidden" name="u" value="" />
    <select name="langpair" onchange="this.form.submit()">
    <option value="" selected="selected">Translate</option>
    <option value="en|it">Italian</option>
    <option value="en|de">German</option>
    <option value="en|es">Spanish</option>
    <option value="en|fr">French</option>
    <option value="en|pt">Portuguese</option>
    <option value="en|ar">Arabic</option>
    <option value="en|ja">Japanese</option>
    <option value="en|ko">Korean</option>
    <option value="en|zh-CN">Chinese (S)</option>
    </select>
    <input type="hidden" name="hl" value="en" />
    <input type="hidden" name="ie" value="UTF8" />
    <br />
    <input type="submit" value="Translate" name="sub" />
    </form>
    <script type="text/javascript">
    document.forms['translateForm'].elements['sub'].style.display = "none";
    </script>
    </table>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey,

    This unfortuntely does not work. It generates a url of http://www.google.com/translate_t

    It does not grab the page info, that langpair has been getting my goat for a while.

    You can see how it works on code-of-ethics dot org, keep in mind the site changes often as I am still hammering out design and other scripts.

    Thanks!

    Mark

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Really? I see no reason why it would...
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey,

    Not to be pushy but, does that mean this is something you wish to pursue or is this dead?

    Regards,

    Mark

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    No, no, I haven't given up on you An URL would be nice though.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Twey,

    Thank you, thank you, thank you.

    I am trying to keep the spiders from finding the web site at this point, so I broke the URL apart. The url is www dot code-of-ethics dot org

    Kindest Regards,

    Mark

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •