No, I cant seam to get it to work that way eaither, i thought a big IF statment would do the trick and have tried loads of times with out suscess.
So i gave up with that old version and now i'm trying this, with htaccess to turn the pages in to html
But again the outward bound links have the Google translator url ie.
http://66.249.93.104/translate_c?hl=en&ie=UTF-8&oe=UTF-8&langpair=en%7Cde&u=http://www.the-outward-link-site.com
function Translate($aLanguage, $aRelativePath)
{
$MySiteURL = "http://www.this-is-my-site.com";
$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 = $aLanguage;
$url = $MySiteURL . $aRelativePath;
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);
$lReplaceStr = "|http://([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/translate_c(.*)&u=" . $MySiteURL . "|Ui";
$GetPage = preg_replace(
$lReplaceStr,
$MySiteURL."/lang/".$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("/lang/".$language."/lang", "/lang", $GetPage);
$GetPage = str_replace("/lang/en/", "/", $GetPage);
$GetPage = str_replace("/lang/en/", "/", $GetPage);
$GetPage = str_replace("<!-- English Tran Flag -->", "<a href=\"" . $url . "\"><img src=\"/lang/images/en.gif\" alt=\"English\" /></a>", $GetPage);
echo $GetPage;
}
else
{
echo "Temporary failure. Please try again later. Sorry for the inconvenience.";
}
}