Guys,
Here's a nice php script for google translation. When following the authors suggestions I upload a folder such as.
translate -- to a directory on my site
-- a seperate folder for each language contains a php script for that particular language
I am using multimenu to diplay the language icons and using a relative url that points to the language folder containing the script.
Works great, but only translates the first page. When I click on links deeper into my site I'm back into english.
When I click on an icon to translate while in a subpage I get dumped back to the main page.
What am I missing? Is there a better way to do this. Help would be appreciated.
Here's my
siteHere's a copy of the script.
$translator_base_url = 'http://translate.google.com/translate_c?hl=en&prev=/language_tools&ie=UTF-8&oe=UTF-8&langpair=en%7C';
@set_time_limit(180);
$language = "es";
$MySiteURL = "http://www.sbe38.org";
$url = $MySiteURL.$_SERVER["QUERY_STRING"];
if(function_exists('curl_init')) {
$ch = curl_init();
$resource = $translator_base_url . $language . '&u=' . $url;
curl_setopt($ch, CURLOPT_URL, $resource);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); // Increase IE Stats! Google dislikes non-browser user agents :(
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
$GetPage = curl_exec($ch);
curl_close($ch);
$GetPage = str_replace("&", "&", $GetPage);
$GetPage = str_replace("&prev=/language_tools", "", $GetPage);
$GetPage = str_replace("http://216.239.39.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7C".$language."&u=".$MySiteURL, $MySiteURL."/translate/".$language."/?", $GetPage);
$GetPage = str_replace("http://216.239.37.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7C".$language."&u=".$MySiteURL, $MySiteURL."/translate/".$language."/?", $GetPage);
$GetPage = str_replace("charset=iso-8859-1", "charset=utf-8", $GetPage);
$GetPage = str_replace("%23", "#", $GetPage);
$GetPage = str_replace("%3F", "?", $GetPage);
$GetPage = str_replace("/translate/".$language."/?/translate", "/translate", $GetPage);
echo $GetPage;
} else {
echo "Temporary failure. Please try again later. Sorry for the inconvenience.";
}
?>
don (el paso)