5000 Characters Length Limit Of Google Ajax Language API

Google Ajax Language API allow translating and detecting the language of blocks of text within a webpage using only JavaScript. However, it has a characters length limit of 5000 for input text (see it’ terms). Although you should even can’t translate a text longer than about 1000 characters if you don’t use a Javascript Proxy to solve Cross Domain problems and transfer POST request, because the limit of URL length.

I have written a simple Javascript Proxy in PHP, it only accepts POST method. (Most javascript APIs allow using jsonp in GET method.)

 'Wed, 11 Jan 1984 05:00:00 GMT',
	'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
	'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
	'Pragma' => 'no-cache',
	'Content-Type' => 'text/javascript; charset=UTF-8',
	'Content-Length' => strlen($result)
);
foreach( $headers as $name => $field_value )
	header("{$name}: {$field_value}");

echo $result;
curl_close($session);

Usage:
Just send your POST request to yourproxy.php?url=POSTURL instead of directly to POSTURL.

I used this proxy to develop a feature that translate the whole webpage into another language using Google Ajax Language API. Sadly I found the Google’s Limit that if you POST a text longer then 5000 characters, Google Server will return a error “exceed string length limit”. I am exploring other open translation APIs, such as Microsoft Translator AJAX API. However, Microsoft’s Docs seems to be more complex ( and ugly = = ) than Google’s.

BTW: why google and other web APIs which can be accessed via javascript don’t support Cross-Origin Resource Sharing? It seems currently only Twitter and YQL support this standand.