Invalid value (400) using google translate api
Asked Answered
E

4

7

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?

Eerie answered 17/2, 2015 at 20:35 Comment(3)
Your api key is invalid?Quoin
api key is fine, I just didn't post it here )Eerie
This error is encounterd when the target language code is invalid. By invalid means its not in the list of languages supported by Google translate API.Scoutmaster
E
12

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

Eerie answered 11/3, 2015 at 10:19 Comment(2)
I had the same thing, but it was where I was using "kr" or Korea instead of "ka". (Which is a little nuts, because the Google Cloud Natural Language API uses "kr" for Korea and I just assumed the two APIs were standardized in their choice of two-letter country codes. THAT's something that should get fixed...)Bilek
Country codes are different from Language codes. Korean language is "ko". en.wikipedia.org/wiki/…Quarrelsome
C
3

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

Cutty answered 11/3, 2015 at 22:38 Comment(0)
A
3

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

Admonish answered 25/2, 2021 at 0:17 Comment(0)
S
0

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.

Sophistry answered 9/9 at 15:57 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Chiao

© 2022 - 2024 — McMap. All rights reserved.