How to translate the result of "google.loader.ClientLocation.address.city" google.loader.ClientLocation.address.city

118 views
Skip to first unread message

badnews

unread,
Jul 8, 2009, 2:48:56 AM7/8/09
to Google AJAX APIs

I get result with "google.loader.ClientLocation.address.city"


the result is "Beijing" ,chinese capital.


How to translate the result into chinese ?





Jeremy Geerdes

unread,
Jul 8, 2009, 9:48:42 AM7/8/09
to Google-AJAX...@googlegroups.com
Two thoughts:

1. What happens if you specify an hl parameter when you call the
loader? E.g.:

http://www.google.com/jsapi?hl=zh-Ch...

2. If that doesn't make any difference, you can run it through the
Translation API.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
jgee...@mchsi.com

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!

And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com
!

badnews

unread,
Jul 9, 2009, 4:40:23 AM7/9/09
to Google AJAX APIs

thanks

I get chines with Translation API。

I get chinese city name by GClientGeocoder,why?




badnews

unread,
Jul 11, 2009, 12:14:36 PM7/11/09
to Google AJAX APIs

after translated ,
the code "alert(loginRegion + '/')" was showed
after
the code "targets = eval(VisitDb2("9","false`" + escape(loginRegion)
+ "`5",false,false)) ",

It seems that the translation API is asynchronism


code:


GEvent.addDomListener(window,"load",function()
{

var loginCenter = "";
var loginRegion = "";

if (google.loader.ClientLocation)
{
loginCenter = new google.maps.LatLng
(google.loader.ClientLocation.latitude,
google.loader.ClientLocation.longitude);
var city = google.loader.ClientLocation.address.city;

google.language.detect(city, function(result)
{
if (!result.error && result.language)
{
google.language.translate(city, result.language,
"zh",
function(result)
{
if (result.translation)
{
loginRegion = result.translation.replace
("区","").replace("市","").replace("直辖","")
alert(loginRegion + '/')
}
});
}
});
}

targets = eval(VisitDb2("9","false`" + escape(loginRegion) +
"`5",false,false))
}

Jeremy Geerdes

unread,
Jul 11, 2009, 12:33:43 PM7/11/09
to Google-AJAX...@googlegroups.com
You are correct; the Translation API, like all the other AJAX APIs,
are asynchronous.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
jgee...@mchsi.com

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!

And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com
!


冯冀川

unread,
Jul 12, 2009, 2:46:21 AM7/12/09
to Google-AJAX...@googlegroups.com
test

2009/7/8 Jeremy Geerdes <jrge...@gmail.com>

khay44

unread,
Jul 24, 2009, 8:31:28 AM7/24/09
to Google AJAX APIs
Hello,
I have a criticism of your API translation. Sorry.
It is impossible to transfer the result of translation into another
variable Javascript. The utlisation and use of this API translation
remains very limited.
Would vious suggestion so that I can transfer the translation results
in a Javascript variable?

source :
<html>
<head>
<script type="text/javascript" src="http://www.google.com/
jsapi">
</script>
<script type="text/javascript">
google.load("language", "1");
function initialize(ptext, plang ) {
var text = document.getElementById("translation");;
var lang = plang;
google.language.detect(text, function(result) {
if (!result.error && result.language) {
google.language.translate(text, result.language, "en",
function(result) {
if (result.translation) {
var container = document.getElementById
("translation");

var ptext_trad = result.translation;
return ptext_trad;
}
});
}
});
}

function displayArea()
{
var text = "ordinateur";
var lang = "en";
var text_trad;
text_trad = document.getElementById("translation");
text_trad = initialize(text, lang);
document.write("The area is ", text_trad);
}
</script>
</head>
<body>
<div id="lang">en</div>
<div id="text"></div>
<div id="translation"></div>
<Script Language="JavaScript">
displayArea();
</Script>
</body>
</html>


Thank you for your help.


On 11 juil, 18:33, Jeremy Geerdes <jrgeer...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages