I am having an unusual problem with aws sdk on the AWS Translate service.
I need to dynamically translate some response messages, but I get this error.
$currentLanguage = 'es';
// If the TargetLanguageCode is not "en", the SourceLanguageCode must be "en".
$targetLanguage= 'en';
$textToTranslate = 'El AWS SDK for PHP versión 3 permite a los desarrolladores de PHP utilizar Amazon Web Services en su código PHP y crear aplicaciones y software robustos utilizando servicios como Amazon S3, Amazon DynamoDB, Amazon Glacier, etc. Puede empezar rápidamente instalando el SDK mediante Composer (solicitando el paquete aws/aws-sdk-php) o descargando el archivo aws.zip o aws.phar independiente';
try {
$translate = $this->aws_utils->getTranslate();
$result = $translate->translateText(array(
'SourceLanguageCode' => $currentLanguage,
'TargetLanguageCode' => $targetLanguage,
'Text' => $textToTranslate
));
}catch (AwsException $e) {
// output error message if fails
var_dump($e->getMessage());die;
}
https://docs.aws.amazon.com/translate/latest/dg/API_TranslateText.html
As per the documentation I pass the parameters to the SDK service correctly but I get this error 500: Found 1 error while validating the input provided for the TranslateText operation: [TranslatedText] is missing and is a required parameter
Does anyone know the problem? That field shouldn't be there completely
Change the code to
and it should work