Hey dave, very nice plugin.
I figured it out for you
Code:
<!--notranslatestart-->
Do not translate this text
<!--notranslateend-->
That is the syntax.
Change the plugin code to the following:
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('|<!--notranslatestart-->(.*?)<!--notranslateend-->|si', $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($styletags);$i++)
{
$output = str_replace("<a name=\"t$i\"></a>", $notranslatetags[$i][0], $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));
}
Also you are going to make google angry.
You need to add a
Code:
@curl_setopt($ch, CURLOPT_REFERER,"http://$_SERVER[SERVER_NAME]$_SERVER[VBSEO_URI]");
(this is vbseo only code)
according to google.
and adding an api key to the request doesn't hurt.
http://code.google.com/apis/ajaxsearch/signup.html
at
http://code.google.com/apis/ajaxlanguage/documentation
it says:
Quote:
Flash and other Non-Javascript Environments
For Flash developers, and those developers that have a need to access the AJAX Language API from other Non-JavaScript environments, the API exposes a simple RESTful interface. In all cases, the method supported is GET, and the response format is a JSON encoded result with embedded status codes. For google.language.translate, the POST method is available. Applications that use this interface must abide by all existing terms of use. An area to pay special attention to relates to correctly identifying yourself in your requests. Applications MUST always include a valid and accurate http referer header in their requests. In addition, we ask, but not require, that each request contains a valid API Key. By providing a key, your application provides us with a secondary identification mechanism that is useful should we need to contact you in order to correct any problems.
|
so basically you just change the request to look like this
Quote:
@curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&key=KEYHERE&langpair=".urlencode($fl.'|'.$tl)."&q=".urlencode ($text));
|