I've been using Cloud Translation with this package for a months now and suddenly it stared throwing weird exception:
Google\ApiCore\ApiException: {
"message": "Target language can't be equal to source language.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": 0,
"data": "type.googleapis.com\/google.rpc.BadRequest"
},
{
"@type": 0,
"data": [
{
"field": "source_language_code",
"description": "Source language: pol"
},
{
"field": "target_language_code",
"description": "Target language: por"
}
]
}
]
}
As you can see, language codes are clearly different. That happens with any language pair.
$client = new TranslationServiceClient();
$projectId = self::key(true)->project_id;
$formattedParent = $client::locationName($projectId, 'us-central1');
$client->translateText(
['Test'],
'en',
$formattedParent,
['sourceLanguageCode' => 'pl']
)->getTranslations();
Anybody else ran into this error and knows a fix?
I changed all language codes from 2 letters to 3 letters - from pl, de, en to pol, ger, eng. Now it works.