Length of translation for API

957 views
Skip to first unread message

Yuiry Saprykin

unread,
Dec 21, 2009, 3:23:04 PM12/21/09
to Google AJAX APIs
What is the maximum length of text for translation may be given to
Google's API?
I read rules, there is mentioned 5000 charcters, but in fact when the
text is larger then 350 characters google.language.translate fails
with no response at all! Whats up?

Jeremy Geerdes

unread,
Dec 21, 2009, 4:55:19 PM12/21/09
to google-ajax...@googlegroups.com
You can send source strings of up to 5,000 characters, but there are a
few provisos that are sometimes lost.

First, you can only send the 5,000 characters via the POST method. In
other words, you can't use the AJAX side of the API. If you want to do
the translation in a browser, you will have to (a) write your own
client-side Javascript API utilizing XMLHttpRequest and (b) write your
own server-side proxy script which will accept the request from the
browser, relay it to Google and get the response back, and then return
the response to the client.

Second, if you do use the default AJAX interface, you are limited to
submitting requests via the GET method, and Google has placed an appr.
2,000-character length limit on urls. If a url is longer than that,
Google's servers will just reject it. It should be noted that, within
this 2,000-character limit, you must also count the path and the rest
of the query string as well. So your 2,000 characters quickly dwindles
to more like 1,250 or so.

And finally, all of these limits are AFTER the string has been uri
encoded. In other words, every space becomes a %20, every quotation
mark a %22, and every non-Latin character its own uri-encoded entity.
For non-Latin languages (e.g., Chinese, Japanese, Urdu, Russian,
etc.), this can very quickly add up so that you run out of characters
pretty fast.

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
!

> --
>
> You received this message because you are subscribed to the Google
> Groups "Google AJAX APIs" group.
> To post to this group, send email to google-ajax...@googlegroups.com
> .
> To unsubscribe from this group, send email to google-ajax-searc...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/google-ajax-search-api?hl=en
> .
>
>

Yuiry Saprykin

unread,
Dec 23, 2009, 12:56:08 PM12/23/09
to Google AJAX APIs
That's explain a lot. Thank you! I didn't expected to get a reply, but
impressed with you guys!

> jgeer...@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, athttp://jgeerdes.blogspot.com

omr

unread,
Dec 26, 2009, 2:13:12 AM12/26/09
to Google AJAX APIs
Jeremy Geerdes wrote:
> ... Google has placed an appr. 2,000-character length limit on urls. ...

See also comment #13
at the bottom of this page:

http://code.google.com/p/google-ajax-apis/issues/detail?id=150#c13

As noted there, the 2K limit (which "affects many services") is
"the safe approach", given Internet Explorer's limitation on URL
length.

-- omr

Reply all
Reply to author
Forward
0 new messages