If you want, you can save some time by using the script from
http://languagecache.com  Just take the include file (or just include
it).  There's a script called "translate_objects('div'', "whatever
your new language should be')" (or whatever object you have).  And it
will loop through the div tags on your page, pull out the ones where
the language isn't equal to whatever your new langauge should be, and
then replace them with the translation.  Just make sure the div is
<div lang=en>hello world</div>  (or span, var, whatever)

You can see a working sample of a couple pages all linked together
here: http://languagecache.com/test/  If you just cut and paste the
source to your desktop, it should still work fine.  I'm not sure how
long that stuff will be there, since the site is about 2 weeks old,
but for now it is free, available, and seems to work.  I'm sure you
can twist it around to see how your own problem may be solved.  (then
again, I really suck at javascript, so.....  you may be way ahead of
me already!)

-Dan


On Sep 25, 6:28 am, "Jeremy R. Geerdes" <[EMAIL PROTECTED]> wrote:
> Did you see this thread?
>
> http://groups.google.com/group/Google-AJAX-Search-API/browse_thread/t...
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project quote:http://jgeerdes.home.mchsi.com
> [EMAIL PROTECTED]
>
> Unless otherwise noted, any price quotes contained within this  
> communication are given in US dollars.
>
> If you're in the Des Moines, IA, area, check out Debra Heights  
> Wesleyan Church!
>
> On Sep 25, 2008, at 6:06 AM, karan deep geddam wrote:
>
>
>
> > Hi,
>
> > Please find my html page:
>
> > {
> > <html>
> > <head> Test Page
> > <script type="text/javascript" src="http://www.google.com/jsapi";>
> > </script>
> > <script src="script.js" type="text/javascript">
> > </script>
> > <script type="text/javascript">
> > google.load("language", "1");
> > google.setOnLoadCallback(function(result)
> > {
> >  alert("Load Completed");
> > });
> > </script>
> > </head>
> > <body>
> > <div id="test">
> > The Input Text is: Hello
> > <br/>
> > <button type="submit" onClick="onSubmit();">Submit</button>
> > </div>
> > <div id="translation">
> > </div>
> > </body>
> > </html>
> > }
>
> > JavaScript Page:
>
> > {
>
> > function onSubmit()
> > {
> >  alert("on Submit");
> >  google.language.translate("hello", "en" , "es", function(result)
> >  {
> >  alert("in handle result");
> >  if (!result.error)
> >  {
> >   var translated = document.getElementById("translation");
> >   translated.innerHTML = "<p>The translated text is:</p><br/
> > >"+result.translation;
> >  }
> >  });
> > }
>
> > }
>
> > The above works perfectly fine. However if I use the below:
>
> > html page:
> > {
> > <html>
> > <head> Test Page
> > <script type="text/javascript" src="http://www.google.com/jsapi";>
> > </script>
> > <script src="script.js" type="text/javascript">
> > </script>
> > </head>
> > <body onload="onStartup();">
> > <div id="test">
> > The Input Text is: Hello
> > <br/>
> > <button type="submit" onClick="onSubmit();">Submit</button>
> > </div>
> > <div id="translation">
> > </div>
> > </body>
> > </html>
> > }
>
> > JavaScript File:
>
> > {
>
> > function onStartup()
> > {
> > google.load("language", "1");
> > google.setOnLoadCallback(function(result)
> > {
> >  alert("Load Completed");
> > });
> > }
>
> > function onSubmit()
> > {
> >  alert("on Submit");
> >  google.language.translate("hello", "en" , "es", function(result)
> >  {
> >  alert("in handle result");
> >  if (!result.error)
> >  {
> >   var translated = document.getElementById("translation");
> >   translated.innerHTML = "<p>The translated text is:</p><br/
> > >"+result.translation;
> >  }
> >  });
> > }
>
> > }
>
> > The page load never happens.
>
> > Can you please suggest a way I can perform the language api loading  
> > externally from the javascript file?
>
> > If it cannot be achieved now can this be addressed in the near future?
>
> > Cheers,
> > Bobby- Hide quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to