今天同事要写程序翻译点东西,找到了一个封装了的class,但是有些内容翻译出来不对。仔细看了下,主要是大数据量的和一些带html代码的数据,遂对代码做了细微的更改,并把api的参数等等的说明都收集放在了文件末尾,方便查看。
<?php
/**
* @author bombworm@gmail.com
* @联系方式 QQ 79194034
* @link http://www.codingall.com
* @version 1.0
* @license remain this copyright when using
* @abstract Translate a large piece of text with the Google Translate API
* @tutorial http://code.google.com/intl/en/apis/ajaxlanguage/documentation/reference.html
* @example
* Google_Translate_API::translate('write codes, go " http://www.codingall.com "', 'en', 'zh-cn');
*/
/**
* Translating language with Google API
* @author gabe@fijiwebdesign.com
* @version $id$
* @license - Share-Alike 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
*
* Google requires attribution for their Language API, please see: http://code.google.com/apis/ajaxlanguage/documentation/#Branding
*
*/
class Google_Translate_API {
/**
* Translate a piece of text with the Google Translate API
* @return String
* @param $text String
* @param $from String[optional] Original language of $text. An empty String will let