google| Online
Sometimes you want to provide multi-language support for our web pages, and if one language is too cumbersome to do with a single Web page, it is fortunate that Google offers the Language Tools feature, and here's how to use it to translate between multiple languages on a Web page.
Lan.htm
<form>
<select name= "LAN" >
<option value= "En|de" > English translation into German </option>
<option value= "En|es" > English translation into Spanish </option>
<option value= "EN|FR" > English translation into French </option>
<option value= "En|it" > English translation into Italian </option>
<option value= "en|pt" > English translation into Portuguese </option>
<option value= "En|ja" > English translation into Japanese beta</option>
<option value= "En|ko" > English translated into Korean beta</option>
<option value= "EN|ZH-CN" > English translation into Chinese (Simplified) beta</option>
<option value= "De|en" > German translated into English </option>
<option value= "De|fr" > German translated into French </option>
<option value= "Es|en" > Spanish translated into English </option>
<option value= "Fr|en" > French translation into English </option>
<option value= "Fr|de" > French translated into German </option>
<option value= "It|en" > Italian translated into English </option>
<option value= "Pt|en" > Portuguese translated into English </option>
<option value= "Ja|en" > Japanese translation into English beta</option>
<option value= "Ko|en" > Korean translated into English beta</option>
<option value= "Zh-cn|en" > Chinese (Simplified) translated into English beta</option>
<input style= "font-size:12px" type= "button" value= "go->" name= "Button1" >
</select>
</form>
The content in the lan.htm is used to select the language to be translated, including the original language and the language to be translated. All we need to do is copy the contents of the lan.htm to the page that provides the multilingual translation.
Translate.asp
<title> Online Translator </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<body>
<%
' On Error Resume Next
' If the speed is slow, you can adjust the following time. Per second
Server.ScriptTimeout = 999999
'========================================================
' Character encoding function
'========================================================
Function Bytestobstr (Body,code)
Dim objstream
Set objstream = Server.CreateObject ("ADODB.stream")
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset =code
Bytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function
The position in another string where the ' fetch ' string appears
Function newstring (WSTR,STRNG)
Newstring=instr (LCase (WSTR), LCase (STRNG))
If Newstring<=0 then Newstring=len (WSTR)
End Function
' Replace string function
function Replacestr (ORI,STR1,STR2)
Replacestr=replace (ORI,STR1,STR2)
End Function
'=====================================================
function ReadXml (url,code,start,ends)
Set Osend=createobject ("Microsoft.XMLHTTP")
SourceCode = Osend.open ("Get", Url,false)
Osend.send ()
Readxml=bytestobstr (Osend.responsebody,code)
if (start= "" or ends= "") Then
Else
Start=newstring (Readxml,start)
Readxml=mid (Readxml,start)
Ends=newstring (Readxml,ends)
Readxml=left (readxml,ends-1)
End If
End Function
Dim Urlpage,lan
Urlpage=request ("URLs")
Lan=request ("LAN")
%>
<form method= "POST" action= "translate.asp" >
<input type= "text" name= "URLs" size= "value=" "<%=urlpage%>" >
<input type= "hidden" name= "LAN" value= "<%=lan%>" >
<input type= "Submit" value= "Submit" >
</form>
<%
Dim Transurl
Transurl= "Http://216.239.39.104/translate_c?hl=zh-CN&ie=UTF-8&oe=UTF-8&langpair=" &server. UrlEncode (LAN) & "&u=" &urlpage& "&prev=/language_tools"
if (Len (urlpage) >3) Then
Getcont=readxml (Transurl, "gb2312", "", "")
Response. Write (Getcont)
End If
%>
</body>
Translate.asp implements the translation function, which is achieved by using Google's language tools.
Note that the encoding used for translate.asp files is "Utf-8" that supports all characters because it provides multilanguage support