File: /var/www/clients/client125/web350/web/wp-content/plugins/wp-automatic/test2.php
<?php
function translate_word($en){
$file_content = file_get_contents('http://translate.google.com/translate_a/t?client=p&sl=auto&tl=ar&hl=en&sc=2&ie=UTF-8&oe=UTF-8&uptl=ar&oc=1&prev=conf&psl=auto&ptl=en&otf=1&it=sel.8936&ssel=0&tsel=3&q='.str_replace(" ","%20",$en));
echo $file_content;
$obj = json_decode($file_content);
print_r($obj);
if(!empty($obj->sentences[0]->trans)){
return $obj->sentences[0]->trans;
}else{
return $en;
}
}
//how to use
echo translate_word("test translation process");
?>