Some of these may not be applicable in your situation, but three things to think about when using the Translate API from PHP especially:
PHP uses the ISO-8859 character set by default. The Google Translate API assumes UTF-8. This isn't a huge deal, but it does mean that, if you haven't altered the default char set, whenever you are dealing with UTF-8, you need to use the encode_utf8 and decode_utf8 functions. And when you're sending data to the Translate API, you need to use urlencode to encode information. When you use urlencode, spaces will be automatically translated to %20. The Translate API is really not designed to translate individual words. It works dramatically better on phrases, and better yet on entire sentences. Because it was designed to work better on longer strings, when you provide a simple list of words, it will try to make some sense of them. This means that you may get the translations back in a crazy order, conjugated incorrectly, etc. If you have a simple list of words, I would suggest sending them each individually, but there are some tricks to doing this: You can't use automated queries, so you need to make sure that you're having some sort of manual interaction with the application. You'll want to space individual requests by a second or two. It will be easier to use Translate API v2 because it (theoretically) supports the submission of up to 128 q arguments in one request. This means fewer requests for your application. BUT - and this is a huge but - there is currently a bug in the system that causes translated strings to be returned in a random order, rather than the order in which they were submitted. You may want to wait for that to get ironed out. Be mindful of rate limits. The Translate API v1 is limited dynamically. This means that there is no hard upper limit on the number of requests you can send and/or translations you can receive, but if you send too many at once, you will be throttled. And Translate API v2 has a hard limit of 100,000 characters per day. So you may need to split your project over several days. You'll probably want to use the POST method. So, to answer your first question: make sure you're using urlencode to construct your query string. And, to answer your second question: use Translate API v2 and send each word as a separate q argument, as below: q=word1&q=word2&q=word3&q=word4... Jeremy R. Geerdes Generally Cool Guy Des Moines, IA For more information or a project quote: [email protected] If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! On Apr 23, 2011, at 2:56 AM, [email protected] wrote: > Hi all,I am from russia,that why i need use cyrillic(utf-8? > windows-1251 charsets) > So,the problem is in php > <? > $rus_word="путин"; > echo mb_detect_encoding($rus_word); //--UTF-8 > //etc.. > ?> > then google api and JSON > Json understeng link with $rus_word as "%B%B%B%....etc" > and no search results for tht query. > So, how find rus words by google search api? > > second question: > i decided nake a transcript of russian words,it is ok. but how send > SPACE between words? > example: > word1="word1" > word2="word2" > google searrch: ..&q=word1_word2 OR replace "_" by "+" or how? > > -- > You received this message because you are subscribed to the Google Groups > "Google AJAX APIs" 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. > -- You received this message because you are subscribed to the Google Groups "Google AJAX APIs" 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.
