想做个东西简体转繁体,找到微软的API可用:
http://msdn.microsoft.com/en-us/library/ff512423.aspx
感觉这个要比GOOGLE的好,因为微软的接口会将一些词汇差异也体现出来,比如"服务器"转换为"伺服器","软件"转换为"软体".
http://msdn.microsoft.com/en-us/library/ff512423.aspx
感觉这个要比GOOGLE的好,因为微软的接口会将一些词汇差异也体现出来,比如"服务器"转换为"伺服器","软件"转换为"软体".
package test;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class Test {
public static void main(String[] args) throws Exception{
//message to be translated
String str = "服务器硬盘软件数据库程序设计";
String method = "Translate";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL("http://api.microsofttranslator.com/V2/Soap.svc"));
call.setOperationName(new QName("http://api.microsofttranslator.com/V2",method));
call.addParameter(new QName("http://api.microsofttranslator.com/V2","appId"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://api.microsofttranslator.com/V2","text"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://api.microsofttranslator.com/V2","from"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://api.microsofttranslator.com/V2","to"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING);
call.setSOAPActionURI("http://api.microsofttranslator.com/V2/LanguageService/Translate");
String result = (String)call.invoke(new Object[]{"YOUR APPID HERE",str,"zh-CHS","zh-CHT"});
//result
System.out.println(result);
}
}