
![]() |
KaptainKrayola
Quick, simple, effective. You need the Snoopy class to make it work. Enjoy
![]() 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
PHPrepos. I guess Cold Fusion is thawing out, ef?![]() You go, Kapn. /p KaptainKrayola
Watch out, the Kaptain may be posting some stuff in the C# section also.
![]() CF is still a decent language but the Kaptain has had little use for it lately. PHPis 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 ![]() 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 PHPclass:[URL=http://www. phpclasses.org/browse/package/3898.html]http://www.phpclasses.org/browse/package/3898.html[/URL]Or maybe this code in PHP5 till Google API allows do that....<? phpclass Google_API_translator { public $opts = array("text" => "", "language_pair" => "en|it"); public $out = ""; function __construct() {} function setOpts($opts) { if($opts["text"] != "" ![]() if($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"] != "" ![]() $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" ![]() $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...
![]() 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.
![]() 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 perly the words...#### ######What Translator Calls do you use for your auto translationg articles dudeS? ######## Slime |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads