Text Translate Script using Google

Jesse

Active Member
Messages
1,360
Reaction score
0
Points
36
I need help. This code was working but suddenly stopped one day.

The website where script is being used ::
http://www.xtranslate.info/

Anyone knows how to fix this?

This is the contents of translate.php
PHP:
<?php
function getstring($a,$b,$c){ 
$y = explode($b,$a);
$x = explode($c,$y[1]);
return $x[0];
}
// Check if form has been submitted
if($_REQUEST['txt']){
    ini_set("max_execution_time", 0);      // no time-outs!
    ignore_user_abort(true);            // Continue downloading even after user closes the browser.
    $text = stripslashes($_REQUEST['txt']);
    $lang1 = $_REQUEST['lang1'];
    $lang2 = $_REQUEST['lang2'];
echo translate($text,$lang1,$lang2);
} 
else { echo "<center>You can't access this file directly! redirecting to home page now.</center>";     
?><meta http-equiv="REFRESH" content="3;url=index.php"><?
exit;}
        function translate($text,$lang1,$lang2){
$query = "js=n&prev=_t&hl=en&ie=UTF-8&sl=$lang1&tl=$lang2&text=$text";
        $ch=curl_init();
        //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_URL, "http://translate.google.com/translate_t?");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
        curl_setopt($ch, CURLOPT_ENCODING , "UTF-8");
        $output = curl_exec($ch);
//       echo $output;
        curl_close($ch);
if ($lang2=="ar" || $lang2=="iw") {
$body = getstring($output, "<table><tr><td valign=top>noun</td><td>", "</td></tr><tr><td><a");
if ($body==""){
$body = getstring($output, "<div id=result_box dir=\"rtl\">", "</div>");
}
$prefix="<br><br>";
$body=$prefix.$body;
return $body;
    }

if ($lang2=="fr") {
$body = getstring($output, "<table><tr><td valign=top>noun</td><td>", "</td></tr><tr><td><a");
if ($body==""){
$body = getstring($output, "<div id=result_box dir=\"ltr\">", "</div>");
}
$prefix="<br><br>";
$body=$prefix.$body;
return str_replace("é", "é", $body); }

else {
$body = getstring($output, "<table><tr><td valign=top>noun</td><td>", "</td></tr><tr><td><a");
if ($body==""){
$body = getstring($output, "<div id=result_box dir=\"ltr\">", "</div>");
}
$prefix="<br><br>";
$body=$prefix.$body;
return str_replace("é", "é", $body); }
}
?>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Normally, I'd say that if you want help, include a description of both the behavior you expect and the behavior you get. In this case, I won't offer any help. The script probably breaks Google's Terms of Service and might be illegal. Passing of Google's translation services as your own is certainly unethical.
 

espfutbol98

New Member
Messages
200
Reaction score
2
Points
0
Normally, I'd say that if you want help, include a description of both the behavior you expect and the behavior you get. In this case, I won't offer any help. The script probably breaks Google's Terms of Service and might be illegal. Passing of Google's translation services as your own is certainly unethical.

besides... computer translators are a complete waste of time because of their horrible inaccuracies. I have a suggestion though, if you know a different language, do a paid or free translation service via forms or email. An example site is learn-croatian.com. Instead of doing something illegal, it helps people and is more accurate. Just a thought though.
 
Top