PHP | Google Translate API doesn't translate FR text
one text
I use GoogleTranslateV2, The function works with any other language - except 'fr' (French).
Here's the function:
function translate($lang) {
global $google_translation, $post_heading, $post_subtitle;
//The data you want to send via POST
$fields = [
'q' => array($post_heading,$post_subtitle),
'target' => $lang,
'format' => 'text',
'source' => 'en',
'key' => $gtranslate_key
];
//url-ify the data for the POST
$fields_string = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', http_build_query($fields));
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $google_translation);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
return json_decode($result, true);
}
I tried several other languages, every other language works. When I try to translate to French, I get the response in English (not translated). I see no reason for this to happen, is there something I'm missing?
Source