Jakob Alexander Eichler
Jakob Alexander Eichler

Reputation: 3056

How to detect if the Google's Translate API fails to translate?

I am using the Google Translate API 2 now, because 1 is no longer available. My query results threw the javascript API look like this:

    {
     "data": {
      "translations": [
       {
        "translatedText": "Haus"
       },
       {
        "translatedText": "Übersetzung"
       },
       {
        "translatedText": "sdhksjhks"
       }
      ]
     }
    }

As you see "sdhksjhks" is a translation error, because I did not give the translator a word which it knew. How can I detect this error?

In the API Version 1 a field named 'responseStatus' was returned for every translation.

Upvotes: 0

Views: 219

Answers (1)

TeckniX
TeckniX

Reputation: 673

Using the Translate API, if the word you're getting back is the same as the word you sent, then no translation was needed/found. Otherwise your input and output will differ.

Probably not the answer you're looking for, but what I've noticed.

Upvotes: 1

Related Questions