KaptainKrayola

Quick, simple, effective.  You need the Snoopy class to make it work.  Enjoy Applause
include("Snoopy.class.

php

 ");
function translate($content,$inlang,$outlang){
        $snoopy = new Snoopy;
        //http://google.com/translate_t?hl=en&ie=UTF8&text=eat+pie&langpair=en%7Cit
$trans_url = "http://google.com/translate_t?hl=en&ie=UTF8&text=".urlencode($content)."&langpair=".$inlang."|".$outlang;
$page = $snoopy->fetch($trans_url);
$page = $snoopy->results;

//parse out the data we need
preg_match("/<divs+id=result_boxs+dir=ltr>(.*?)</div>/i",$page,$match);

return $match[1];
}

perkiset

Lookatchu bad pirate posting in the

PHP

  repos. I guess Cold Fusion is thawing out, ef?  Applause

You go, Kapn.
/p

KaptainKrayola

Watch out, the Kaptain may be posting some stuff in the C# section also.  Applause

CF is still a decent language but the Kaptain has had little use for it lately. 

PHP

  is nice because 9 times out of 10 you nerds have already done all the hard work for us so we can just butcher your code and away we go.  Hooray code butchery!

m0nkeymafia

Nice dude nice

basura

quote author=KaptainKrayola link=topic=225.msg1415#msg1415 date=1179262783

Quick, simple, effective.  You need the Snoopy class to make it work.  Enjoy Applause
include("Snoopy.class.

php

 ");
function translate($content,$inlang,$outlang){
        $snoopy = new Snoopy;
        //http://google.com/translate_t?hl=en&ie=UTF8&text=eat+pie&langpair=en%7Cit
$trans_url = "http://google.com/translate_t?hl=en&ie=UTF8&text=".urlencode($content)."&langpair=".$inlang."|".$outlang;
$page = $snoopy->fetch($trans_url);
$page = $snoopy->results;

//parse out the data we need
preg_match("/<divs+id=result_boxs+dir=ltr>(.*?)</div>/i",$page,$match);

return $match[1];
}









Try this

PHP

  class:

[URL=http://www.

php

 classes.org/browse/package/3898.html]http://www.

php

 classes.org/browse/package/3898.html[/URL]

Or maybe this code in

PHP

 5 till Google API allows do that....

<?

php

 
class Google_API_translator {
    public $opts = array("text" => "", "language_pair" => "en|it");
    public $out = "";

    function __construct() {}

    function setOpts($opts) {
        if($opts["text"] != ""Applause $this->opts["text"] = $opts["text"];
        if($opts["language_pair"] != ""Applause $this->opts["language_pair"] = $opts["language_pair"];
    }

    function translate() {
        $this->out = "";
        $google_translator_url = "http://google.com/translate_t?langpair=";
        $google_translator_url .= urlencode($this->opts["language_pair"])."&";
        $google_translator_url .= "text=".urlencode($this->opts["text"]);
        $gphtml = $this->getPage(array("url" => $google_translator_url));
        preg_match('/(.*?)</div>/', $gphtml, $out);
        $this->out = utf8_encode($out[0]);
        return $this->out;
    }

    function getPage($opts) {
        $html = "";
        if($opts["url"] != ""Applause {
            $ch = curl_init($opts["url"]);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 15);
            $html = curl_exec($ch);
            if(curl_errno($ch)) {
                $html = "";
            }
            curl_close ($ch);
        }
        return $html;
    }
}
?>

Implementation Example:

<?

php

 
$g = new Google_API_translator();
$g->setOpts(array("text" => "ciao", "language_pair" => "it|en"Applause);
$g->translate();
echo $g->out;
?>



A good example it could be some others "and more effectives" translators, like Babefish from Y! and TranEx, Russian in translator.ru...

^_^ It could be interesting if someone have done the code.

Slime

perkiset

oh the perk LIKES. I'll betcha that NBs will as well...  Applause

Gonna try that out today just for giggles. Thanks Bas!

/p

nutballs

lol my stuff looks bad enough already, if i ran it through a translator i think it would turn into martianese.

perkiset

Does G ban for Martianese? I'll bet that's an untapped resource.

nutballs

no but it already bans for what I do, so making it work probably wouldnt help.  Applause

though actually the strange thing is that my landing sites are starting to rank, and are actually ranking well for some phrases. stupid fishing google.

perkiset

hmmm... perhaps it's time to celebrate and you know "travel somewhere?" hehe...

basura

Ummh, i think that automatic translators desnt do very well his homeworks...

Table of Good translated words, ENGLISH<->SPANISH

www.worldlingo.com
http://www.worldlingo.com/wl/lgtranslate/UP61481/T1/l/es/traductor.html?wl_lp=EN-ES&wl_fl=0&wl_rurl=http%3A%2F%2Fwww.miweb.com

babelfish.altavista.com
http://babelfish.altavista.com/babelfish/tr

www.online-translator.com

Google.
http://translate.google.com/translate_t


All i have managed, doesnt keep the right words, they doesnt translate pro

perl

 y the words...



####
######What Translator Calls do you use for your auto translationg articles dudeS?
########

Slime


Perkiset's Place Home   Politics @ Perkiset's