Prosto Trader
Prosto Trader

Reputation: 3527

Invalid value (400) using google translate api

What's wrong with my request?

I have string in russian: $string = Потенциал, %

I want to translate it to ukrainian with google API:

I urlencode string:

$q = urlencode($string)

And i request google API:

https://www.googleapis.com/language/translate/v2?q=%D0%9F%D0%BE%D1%82%D0%B5%D0%BD%D1%86%D0%B8%D0%B0%D0%BB%2C%20%25&target=ua&source=ru&key=A...

In response I get :

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

What's wrong with my request?

Upvotes: 7

Views: 9689

Answers (4)

Adam Philip
Adam Philip

Reputation: 1

I have my target language different in SDL Trados and Google, on google it is Kurdish Sorani with the code (ckb) on Trados it comes as some different names for the same language, which made even AI mad! Central Kurdish Iraq (ckb-IQ) Central Kurdish Iran (ckb-IR) Central Kurdish (- Peros Arabic Iraq (ku -Arab-IQ) Kurdish - Perso-Arabic - Iran (ku -Arab-IR) they are all exactly the same language and dialect and I have told the SDL Trados many many times but not been solved.

Upvotes: 0

Tom
Tom

Reputation: 7794

In my case I was trying to translate to "es-uy" but despite being a valid language code, Google doesn't support it.

Here are the language codes that the API supports: https://cloud.google.com/translate/docs/languages

Upvotes: 3

Shobhit
Shobhit

Reputation: 488

The target should be uk not ua.I think it will resolve the issue.

Upvotes: 3

Prosto Trader
Prosto Trader

Reputation: 3527

Solution was simple. Google has UK letters for ukrainian instead of UA.

Upvotes: 12

Related Questions