国产GV亚洲GVFUCKGV,亚洲欧美自拍偷拍一区二区,亚洲一区二区三区视频,久久精品国产一区二区三区

您現(xiàn)在的位置: 5A農(nóng)業(yè)人才網(wǎng) >> 職場(chǎng)資訊 >> 黑板報(bào) >> 正文

在office中集成翻譯功能以及利用asp、vb6、vb.net開發(fā)翻譯組件

 

三、在ASP中使用

在ASP中使用bingTransLate

在asp中比在vb6中更方便,我們制作2個(gè)文件,1.html和1.asp
1.html是前端通過(guò)ajax與1.asp通訊,1.asp則負(fù)責(zé)處理翻譯過(guò)程,

1. html代碼如下

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>bingTranslate</title>
</head>
<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
<body>
<textarea name="text1" cols="50" rows="10" id="text1"></textarea><br>
翻譯從<select id='lngfrom'>
<option value='en' selected>英語(yǔ)</option>
<option value='zh-CHS'>中文</option></select>
到<select id='lngto'>
<option value='zh-CHS' selected>中文</option>
<option value='en'>英語(yǔ)</option></select>
 
<input type='button' name='trans' id='trans' value='翻譯'>
<br>
<textarea name="text2" cols="50" rows="10" id="text2"></textarea>
<script language="javascript">
$(document).ready(function(){
$("#trans").click(abc);
});
function abc(){
$.post('1.asp',
{Content:escape($("#text1").val()),lngfrom:escape($("#lngfrom").val()),lngto:escape($("#lngto").val())},function (data){ //回傳函數(shù)
$('#text2').html(data);
});
}
</script>
</body>
</html>

1. asp代碼如下
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.Expires=0
response.charset="GB2312"
dim ResponseInfo
call TransLate
response.Write(ResponseInfo)

Sub TransLate()
dim c_WSDL_URL,c_SERVICE,c_PORT,c_SERVICE_NAMESPACE,appID
c_WSDL_URL  = "http://api.microsofttranslator.com/V2/Soap.svc"
c_SERVICE  = "SoapService"
c_PORT = "BasicHttpBinding_LanguageService"
c_SERVICE_NAMESPACE  = "http://tempuri.org/"
appID  = "你的appid"
 Dim str_WSML
    'str_WSML = "<servicemapping>"
    'str_WSML = str_WSML & "<service name='SoapService'>"
    'str_WSML = str_WSML & "<using PROGID='MSOSOAP.GenericCustomTypeMapper30' cachable='0' ID='GCTM'/>"
    'str_WSML = str_WSML & "<types>"
    'str_WSML = str_WSML & "<type name='GetTranslationsResponse' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_GetTranslationsRespo'/>"
    'str_WSML = str_WSML & "<type name='TranslateArray2Response' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_TranslateArray2Respo'/>"
    'str_WSML = str_WSML & "<type name='TranslateArrayResponse' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_TranslateArrayRespon'/>"
'    str_WSML = str_WSML & "<type name='TranslateOptions' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_TranslateOptions'/>"
'    str_WSML = str_WSML & "<type name='Translation' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_Translation'/>"
'    str_WSML = str_WSML & "<type name='TranslationMatch' targetNamespace='http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2' uses='GCTM' targetClassName='struct_TranslationMatch'/>"
    'str_WSML = str_WSML & "</types>"
    'str_WSML = str_WSML & "</service>"
    'str_WSML = str_WSML & "</servicemapping>"

Dim sc_SoapService
set sc_SoapService = server.CreateObject("MSSOAP.SoapClient30")
sc_SoapService.ClientProperty("ServerHTTPRequest") = True
'sc_SoapService.MSSoapInit2 c_WSDL_URL, str_WSML, c_SERVICE, c_PORT, c_SERVICE_NAMESPACE ', str_WSML, c_SERVICE, c_PORT, c_SERVICE_NAMESPACE
sc_SoapService.MSSoapInit c_WSDL_URL, str_WSM'注意這里不能用MSSoapInit2 了
'response.write( sc_SoapService.Detect(appID, "你好"))'可以自動(dòng)檢測(cè)原來(lái)語(yǔ)言
Content=vbsunescape(request("Content"))
lngfrom=vbsunescape(request("lngfrom"))
lngto=vbsunescape(request("lngto"))
ResponseInfo=sc_SoapService.Translate(appID, Content, lngfrom, lngto, "text/plain", "general")
set sc_SoapService=nothing
end sub

  Function VbsUnEscape(str)
    x=InStr(str,"%")
    Do While x>0
        VbsUnEscape=VbsUnEscape&Mid(str,1,x-1)
        If LCase(Mid(str,x+1,1))="u" Then
            VbsUnEscape=VbsUnEscape&ChrW(CLng("&H"&Mid(str,x+2,4)))
            str=Mid(str,x+6)
        Else
            VbsUnEscape=VbsUnEscape&Chr(CLng("&H"&Mid(str,x+1,2)))
            str=Mid(str,x+3)
        End If
        x=InStr(str,"%")
    Loop
    VbsUnEscape=VbsUnEscape&str
End Function
%>
運(yùn)行效果如下
 

 


本文地址:http:///news/n08/201401/12611.html,如要轉(zhuǎn)載,請(qǐng)注明轉(zhuǎn)載自5A農(nóng)業(yè)人才網(wǎng)

上一頁(yè)  [1] [2] [3] [4] 下一頁(yè)

文章錄入:希望的田野    責(zé)任編輯:耕農(nóng) 
【字體: 】【打印此文】【關(guān)閉窗口
相關(guān)文章
    沒(méi)有相關(guān)文章
5A農(nóng)業(yè)人才網(wǎng) 版權(quán)所有 2003- © | 關(guān)于我們 | 聯(lián)系我們 | 服務(wù)條款 | 服務(wù)價(jià)格 | 付款方式 | 幫助中心 | 網(wǎng)站地圖

5A農(nóng)業(yè)人才網(wǎng)(原中國(guó)農(nóng)業(yè)人才網(wǎng))為您提供畜牧人才、種植人才、農(nóng)資人才、食品人才等求職招聘服務(wù)