Just found the source, here's a couple of points.
Why is the translator a class? It only has one method in it and absolutely nothing else. You may as well just have it as a function. Alternatively you could make the API a little more contained and put everything in the class.
Also, the translate function could be a little tidier.
function translate($expression, $from, $to) {
//Check the file reading so that we can throw an error
//if it fails for some reason
if(!$file_contents = file('http://translate.google.com/translate_t?text='.urlencode($expression)."&langpair=$from|$to")) {
return false;
}
//Put it all in one string so that we can run a regex on it
$file_contents = implode("\n", $file_contents);
//Run the regex and catch the match in $matches
if(!preg_match('/<textarea.*?>(.*?)<\\/textarea>/', $file_contents, $matches)) {
return false;
}
return $matches[1];
}
HTH
Bubble