However, it does not return the detected language, so I had to resort to using two requests in order to reimplement the same functionality that I had before with the Google APIs. I also found that it was easier to use the Http and not the Ajax variant of the API. It requires using SimpleXML to get to the data, but at least you do not have to fight with the BOM (Byte-order mark) and quoting.

Shortlink

Comments

Any reason to use simplexml_load_string(file_get_contents()) instead of just simplexml_load_file() ?

Peter C.

Tuesday, May 31st 2011, 10:28 UTC

Derick said:

I had to resort to using two requests...

By using the GetTranslations service, the detected source language and the translation can be found with one request. Admittedly, it's a little bit messy (needing a POST request) but it saves waiting around for two request/response cycles.