468,117 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

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

elamberdor
Hi All!

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

Expand|Select|Wrap|Line Numbers
  1. <p align="center"><font size="2">Translate&nbsp; : 
  2. <SCRIPT language=javascript1.2 type=text/javascript>document.write('
  3. <select name="to_lang" onchange="lp=this.options[this.selectedIndex].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>
  4.  
From here, i've done two things:
- Got rid of the "google frame" onload:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.1" type="text/JavaScript"> if (parent.frames.length > 0) top.location.replace(document.location);</script>
  2.  
then it works also when putting:
'http://www.google.com/translate?hl=en&ie=UTF-8&oe=UTF-8&u=
Expand|Select|Wrap|Line Numbers
  1.  
  2. ' + location.href +'
&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="translate"> or something that when you click a flag, it loads the translated script from google???

Any ideas?
Thanks!
=)
Sep 5 '07 #1
4 2505
phvfl
173 Expert 100+
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:
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.
Sep 5 '07 #2
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,
=)
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.
Sep 5 '07 #3
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! =)
Sep 6 '07 #4
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.    <meta charset="UTF-8">
  5.    <title> Google Translater for Website </title> 
  6. </head> 
  7. <body>
  8. <h2>Your Web Page</h2>
  9.  <p>Click on the dropdown button to translate.</p>
  10.  <p>Translate this page:</p>
  11.  
  12. <div id="google_translate_element"></div>
  13.  
  14.  <script type="text/javascript">
  15.   function googleTranslateElementInit() {
  16.   new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
  17.   }
  18. </script>
  19.  
  20. <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
  21. <p class="notranslate"> This Paragraph will remain same because it is using notranslate class.</p>
  22.  
  23. <p class="translate"> This Paragraph will change because it is using translate class. </p> 
  24. </body>
  25. </html>    
  26.  
Mar 9 '21 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Julie Miles | last post: by
8 posts views Thread by Zak McGregor | last post: by
59 posts views Thread by Mason A. Clark | last post: by
30 posts views Thread by Diane Wilson | last post: by
3 posts views Thread by Stephen Costanzo | last post: by
4 posts views Thread by MikaŽl PLOUHINEC | last post: by
3 posts views Thread by Queez | last post: by
1 post views Thread by dustylane | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.