Ok sorry, first of all here is a small bug fix of what i posted earlier, as it was slightly bugged.
Code:
// Enable UTF-8 characters
if(isset($_GET['hl'])) {
require_once("translate.php");
$output = str_replace('lang="en"', 'lang="'.$_GET['hl'].'"', $output);
header ('Content-type: text/html; charset=utf-8');
// Keep remainders of <style and <script tags!
$time = time(); // Unique Tag Identifier!
preg_match_all('|<script[^>]*>(.*?)</script>|si', $output,$scripttags, PREG_SET_ORDER);
for($i=0;$i<count($scripttags);$i++)
{
$output = str_replace($scripttags[$i][0], "<a name=\"$i\"></a>",$output);
}
//preg_match_all("<style[^>]*>.*</style>",$buffer,$styletags);
preg_match_all('|<style[^>]*>(.*?)</style>|si',$output,$styletags);
for($i=0;$i<count($styletags);$i++)
{
$output = str_replace($styletags[1][$i], "<a name=\"s$i\"></a>",$output);
}
preg_match_all('/<!--ntstart-->.*?<!--ntend-->/s', $output,$notranslatetags, PREG_SET_ORDER);
for($i=0;$i<count($notranslatetags);$i++)
{
$output = str_replace($notranslatetags[$i][0], "<a name=\"t$i\"></a>",$output);
}
$output=callback($output);
// Place back remainders of <style and <script tags!
for($i=0;$i<count($notranslatetags);$i++)
{
$output = str_replace("<a name=\"t$i\"></a>", $notranslatetags[$i][0], $output);
}
$output = str_replace("<!--ntstart-->", "", $output);
$output = str_replace("<!--ntend-->", "", $output);
for($i=0;$i<count($styletags);$i++)
{
$output = str_replace("<a name=\"s$i\"></a>", $styletags[1][$i], $output);
}
for($i=0;$i<count($scripttags);$i++)
{
$output = str_replace("<a name=\"$i\"></a>",$scripttags[$i][0] ,$output);
}
//print_r($scripttags);
//die("c:".count($scripttags).":".count($styletags));
}
As far as making google happy,
( This code will ONLY work if you have VBSEO)
Do this:
1. Open up your translate.php.
find these lines:
Code:
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
change it to:
Code:
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_REFERER,"http://$_SERVER[SERVER_NAME]$_SERVER[VBSEO_URI]");
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
2. Also in translate.php
Go to
http://code.google.com/apis/ajaxsearch/signup.html
Get an api key for your site, copy it
find:
Code:
@curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=".urlencode($fl.'|'.$tl)."&q=".urlencode($text));
change it to
Code:
@curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&key=COPYYOURKEYHERE&langpair=".urlencode($fl.'|'.$tl)."&q=".urlencode($text));
Of course replace "COPYYOURKEYHERE" with the key you got from google.
That's all.
Easy as pie.
This will ensure google knows where the requests are coming from and that they can contact you in case of problems instead of just banning you from all of google by ip.