
nate - 2008-06-02 21:28:19
//I also made en -> es the default for my needs
function translate($expression, $from='en', $to='es')
{
$f = file("http://translate.google.com/translate_t?text=" . urlencode($expression) . "&langpair=$from|$to");
foreach ( $f as $v ) {
if (strstr($v, '<textarea'))
{
$x = strstr($v, '<textarea');
}
}
$arr = explode('</textarea>', $x);
$arr = explode('<td class=almost_half_cell><div id=result_box dir="ltr">', $arr[1]);
$arr = explode('</div></td></tr><tr><td class=submitcell>', $arr[1]);
return $arr[0];
}