How to translate Rss feeds?

gialappas

Regular Member
Joined
Jan 25, 2010
Messages
264
Reaction score
181
Hi!

I need a free service that translate rss feeds from english to italian.

I know yahoo pipes but the translation is bad.
I know feedtranslate-com but now this service is offline.

There are some similar service?

Thanks
 
Ok, here we go using good ol google :D

PHP:
<?

$myRSSfeed='this is the feed';

$mytranslatedRSSfeed= translate($myRSSfeed,'en','it');

function translate($msg,$sl,$tl){

$url="http://translate.google.com/";
$header[] = "Content-type: application/x-www-form-urlencoded;charset=UTF-8";

$msg=utf8_encode($msg);


$agents[] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)";
 $agents[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
 $agents[] = "Opera/9.63 (Windows NT 6.0; U; ru) Presto/2.1.1";
 $agents[] = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
 $agents[] = "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.18) Gecko/20081203 Firefox/2.0.0.18";
 $agents[] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16";
 $agents[] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
curl_setopt ($ch, CURLOPT_POST, 1);
$postString1="js=n&prev=_t&hl=en&ie=UTF-8&text=".urlencode($msg)."&sl=".$sl."&tl=".$tl."&history_state0=&submit=Translate";

curl_setopt ($ch, CURLOPT_POSTFIELDS, $postString1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
 curl_setopt($ch, CURLOPT_HEADER, false);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_USERAGENT, $agents[rand(0,(count($agents)-1))]);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$data = curl_exec ($ch);
flush();
preg_match('/<\/object><\/div><span id=result\_box class=\"(.*?)\_text\">(.*?)<\/span><\/span><\/div><\/div><div id=gt-res-tools class=g-section/si',$data,$match);



if(!isset($match[0])){
return $msg;
}

$data= $match[2];
$data=strip_tags($data);
//echo $data;exit;
$s=array("<",">","lt;","gt;","#39;","quot;");$r=array("<",">","<",">","'",'"');
$data=str_replace($s,$r,$data);

$pattern='/\\\x3d/si';
$data=preg_replace($pattern,'=',$data);
$pattern='/\\\r/si';
$data=preg_replace($pattern,'',$data);
$data=str_replace('</ ','</',$data);
$pattern='/\\\x([a-z0-9A-Z]{2,4})/si';
$data=preg_replace($pattern,'',$data);

return $data;
//return $match[1];
}
?>
 
thanks for your reply.

I need to create a .php file with this code?
 
I found this error:
Fatal error: Call to undefined function: curl_init() in /home/mhd-01/www.********.it/htdocs/test.php on line 22
 
I can't use Curl on my host, there are other solutions?
 
Update: Now I can use CURL in my host.

But there are a problem:
I found a blank page!
There are a error in this script?
 
Where do you get your RSS feed from? I can guess what the problem is. Give me any one of your RSS feeds and I will adapt the script for you
 
Pm sent, thanks for your help
 
I just created a .php file and replace $myRSSfeed='this is the feed'; with my feed. However I just got a blank page. Can you give me a help?
 
Have you fixed the feed translate problem. I have the same problem. Can you help? thanks.
 
Back
Top