+ Reply to Thread
Results 1 to 3 of 3

Thread: Text Translate Script using Google

  1. #1
    Jesse's Avatar
    Jesse is offline Lord Of The Keys Jesse is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Manila, PH
    Posts
    1,357

    Text Translate Script using Google

    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 Code:
    <?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($chCURLOPT_URL"http://translate.google.com/translate_t?");
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($chCURLOPT_POST1);
            
    curl_setopt($chCURLOPT_POSTFIELDS$query);
            
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0");
            
    curl_setopt($chCURLOPT_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); }
    }
    ?>
    x10HOSTING
    Member Since October 2007.

    JESSEMAN.ME
    | iMusicz.net

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Text Translate Script using Google

    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.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    espfutbol98's Avatar
    espfutbol98 is offline x10 Sophmore espfutbol98 is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Zagreb... želim
    Posts
    200

    Re: Text Translate Script using Google

    Quote Originally Posted by misson View Post
    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.

+ Reply to Thread

Similar Threads

  1. Replies: 8
    Last Post: 12-28-2009, 10:37 AM
  2. Hybrid's HTML Lessons
    By Hybrid in forum Tutorials
    Replies: 18
    Last Post: 11-28-2009, 02:12 PM
  3. Replies: 5
    Last Post: 03-07-2008, 08:01 PM
  4. Server UP time Script
    By dharmil in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 04-03-2006, 04:39 PM
  5. |PS|*Blur text Tutorial*
    By |Born2Shoot| in forum Tutorials
    Replies: 7
    Last Post: 06-04-2005, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers