CSS: load a class that translates that pages language???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elamberdor
    New Member
    • Mar 2007
    • 39

    CSS: load a class that translates that pages language???

    Hi All!

    I have a working dropdown language selector powered by google that loads the page in your chosen langauge:

    [code=html]
    <p align="center"> <font size="2">Transl ate&nbsp; :
    <SCRIPT language=javasc ript1.2 type=text/javascript>docu ment.write('
    <select name="to_lang" onchange="lp=th is.options[this.selectedIn dex].value; if(lp!=\'\') window.location =\'http://www.google.com/translate?hl=en &ie=UTF-8&oe=UTF-8&u=http://WWW.WEBSITE.COM/PAGE.ASP</select>
    [/code]
    From here, i've done two things:
    - Got rid of the "google frame" onload:
    [code=javascript]
    <script language="JavaS cript1.1" type="text/JavaScript"> if (parent.frames. length > 0) top.location.re place(document. location);</script>
    [/code]
    then it works also when putting:
    'http://www.google.com/translate?hl=en &ie=UTF-8&oe=UTF-8&u=[code=javascript]
    ' + location.href +'[/code]&langpair=\'+lp ;"
    to make the code load that specific page you're on, so I don't have to cut & paste the URL constantly in the code...


    PROBLEM is, as soon as you start adding css styles to the pages, it freaks!
    the styles go all over the place!

    Is there a way to make some sort of <p class="translat e"> or something that when you click a flag, it loads the translated script from google???

    Any ideas?
    Thanks!
    =)
  • phvfl
    Recognized Expert New Member
    • Aug 2007
    • 173

    #2
    Hi,

    You may want to check the T&Cs but I think that it would be against the terms to automatically remove the Google banners from a page that they have translated. Looking through the Universal terms here the following stands out:
    Originally posted by google
    5.3 You agree not to access (or attempt to access) any of the Services by any means other than through the interface that is provided by Google, unless you have been specifically allowed to do so in a separate agreement with Google. You specifically agree not to access (or attempt to access) any of the Services through any automated means (including use of scripts or web crawlers) and shall ensure that you comply with the instructions set out in any robots.txt file present on the Services.
    If it is determined that you are in breach of terms then it is within Google's power to remove your site from their results, this would generally be very bad and avoided where possible.

    Comment

    • elamberdor
      New Member
      • Mar 2007
      • 39

      #3
      That's okay, i'm realising the script won't work whilst removing the frame now, So that i've scrapped orginal idea .

      That scrapped: Any ideas how it might work?

      Thanks,
      =)
      Originally posted by phvfl
      Hi,

      You may want to check the T&Cs but I think that it would be against the terms to automatically remove the Google banners from a page that they have translated. Looking through the Universal terms here the following stands out:


      If it is determined that you are in breach of terms then it is within Google's power to remove your site from their results, this would generally be very bad and avoided where possible.

      Comment

      • elamberdor
        New Member
        • Mar 2007
        • 39

        #4
        Well, update,

        Even the stripped back me-not-touching-anything to styleize it, when the page refreshes with the google frame, it completely breaks all the css design on the page!


        I know the url of the page changes accordingly, but how do we get it to read our css okay still... Any ideas??

        Thanks! =)

        Comment

        • kuldeepbisht310
          New Member
          • Mar 2021
          • 1

          #5
          Code:
          <!DOCTYPE html>
          <html lang="en">
          <head>
             <meta charset="UTF-8">
             <title> Google Translater for Website </title> 
          </head> 
          <body>
          <h2>Your Web Page</h2>
           <p>Click on the dropdown button to translate.</p>
           <p>Translate this page:</p>
          
          <div id="google_translate_element"></div>
          
           <script type="text/javascript">
            function googleTranslateElementInit() {
            new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
            }
          </script>
          
          <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
          <p class="notranslate"> This Paragraph will remain same because it is using notranslate class.</p>
          
          <p class="translate"> This Paragraph will change because it is using translate class. </p> 
          </body>
          </html>

          Comment

          Working...