Asp+xml to realize the emancipation scheme of multi-language website

Source: Internet
Author: User
asp+|xml| website | multi-language

Create a new XML file with two storage language entries and put it in the languages directory:
Zh-cn.xml

The following is a reference fragment:
<?xml version= "1.0" encoding= "Utf-8"?>
<Languages>
<aboutus> About Us </aboutus>
<product> Product Show </product>
</Languages>

English.xml

The following is a reference fragment:
<?xml version= "1.0" encoding= "Utf-8"?>
<Languages>
<aboutus>about us</aboutus>
<product>Products</product>
</Languages>

Common function (method) functions.asp, placed in the Comm directory:

The following is a reference fragment:
<%
’-------------------
' Function name: Getlang ();
' parameter lang: current language;
' Parameter litem: Set the language term;
' Example: Call Getlang ("ZH-CN", "AboutUs");
' Author:huerreson,huerreson@msn.com
’-------------------
Function Getlang (ByVal lang,litem)
Dim xmldom
If Objcheck ("Microsoft.XMLDOM") Then
Set xmldom = Server.CreateObject ("Microsoft.XMLDOM")
ElseIf Objcheck ("Microsoft.XMLDOM") Then
Set xmldom = Server.CreateObject ("MSXML2. DOMDocument ")
Else
Response.Write (the server does not support Microsoft.) Xmldom ' and ' MSXML2. DOMDocument ', cannot use this feature ')
End If
Xmldom.async = False
Xmldom.load (Server.MapPath ("languages/" & Lang & ". xml"))
Response.Write (XmlDom.documentElement.selectSingleNode (Litem). Text)
Set xmldoc = Nothing
Set xmldom = Nothing
End Function
’-------------------
' Function name: Objcheck ();
' parameter objname: object name;
' Example: Call Objcheck ("Microsoft.XMLDOM");
' Author:huerreson,huerreson@msn.com
’-------------------
Function Objcheck (objname)
On Error Resume Next
Objcheck = False
Set OBJ = Server.CreateObject (objname)
If-2147221005 <> ERR Then
Objcheck = True
End If
Set OBJ = Nothing
End Function
%>

asp+xml Implementation of multi-language Web site application Examples:

the following is a reference fragment:
<!-- 
= = Multi-Language version solution = =
Author: huerrseon,huerreson@msn.com 
-->
<% @LANGUAGE = "VBSCRIPT"  codepage= "65001"%>
<!-- #include  file= "comm/functions.asp"  -->
<style type= "Text/css" >
#NavMenu { border-bottom:1px dashed  #000;}
</style>
<%
dim langquery
Langquery = lcase (Request.QueryString ("Lang")
if not  (IsNull (langquery)  or LangQuery =  "")  then
     langquery  = langquery
Else
    LangQuery =  "Default"
end if
%>
<div id= "Navmenu" ><%call getlang (Langquery, "AboutUs")%></ Div>
<div id= "Switchlangbar" > Language switching <a href= "? LANG=ZH-CN" > Simplified Chinese </a>--<a  href= "? Lang=english" >ENGLSIH</A></DIV>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.