Multi-language concept of asp

Source: Internet
Author: User

Multi-language version is a headache ~ This problem has been mentioned many times. It is simple in principle and requires too much coding.

Simple-> traditional conversion is easier, but the general method of multi-country conversion is as follows:
There must be a language pack and a few copies of the database content,
The Language Pack can use xml and UTF-8 encoding. Of course, the inc file can also be dynamically included, but there is no xml clearance logic.

Localization time and currency. You can use the SetLocale (lcid) function provided by vbs)

Obtain the http header to obtain the browser language and call different language packs.

Xml is used as the language pack.
In fact, it is quite simple, but there are many nodes in the actual code. Here is just an idea. The sample code is as follows:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Lang>
<Ch>
<Username> User Name </username>
<Password> password </password>
<BtnSubmit> submit </btnSubmit>
<BtnReset> Reset </btnReset>
</Ch>
<En>
<Username> username </username>
<Password> password </password>
<BtnSubmit> submit </btnSubmit>
<BtnReset> reset </btnReset>
</En>
</Lang>

-----------------------------
Test. asp
-----------------------------
<%
Function lang (langType, nodeName)
Set xmlDoc = Server. CreateObject ("microsoft. xmldom ")
XmlDoc. load (server. mappath ("lang. xml "))
Langdeskxmldoc.doc umentElement. selectSingleNode ("//" & langType & "/" & nodeName). text
End function
If request ("lang") = "ch" then langType = "ch" else langType = "en"
%>
<A href = 'javascript: location. href = "? Lang = <% if _ fcksavedurl = ""? Lang = <% if "langType =" ch "then response. Write" en "else response. Write" ch "%>" '> language change </a>
<Table width = "50%" border = "0" cellspacing = "0" cellpadding = "0" align = 'center'>
<Tr>
<Td> <% = lang (langType, "username") %> </td>
<Td> <input type = "text" name = "textfield"/> </td>
</Tr>
<Tr>
<Td> <% = lang (langType, "password") %> </td>
<Td> <input type = "text" name = "textfield"/> </td>
</Tr>
<Tr align = "center" valign = "middle">
<Td> <input type = "submit" name = "Submit" value = "<% = lang (langType," btnSubmit ") %>"/> </td>
<Td> <input type = "reset" name = "Submit" value = "<% = lang (langType," btnReset ") %>"/> </td>
</Tr>
</Table>

In actual coding, there will be more code. The first is to make the program more robust, and the second is to reuse the Code better, so there will be more code, the above is just an example.

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.