Multi-language support for ASP program interface

Source: Internet
Author: User
Tags html page
Multi-language support for program ASP program interface

There may be Web applications that require multi-language support, such as a discussion group, with a Chinese interface,
To suit the convenience of people, but also the need for English interface to meet the needs of internationalization. I think
There seems to be no need to write a version for every language, which is not only tedious, but also a process
Sequential upgrades must modify all versions of the program. Familiar with the VC program friends must know that usually
The internationalization of Windows applications is done through RC files. Just rejoin.
The different language version of the RC file compiled on the line.
ASP programs do not compile or compile. So I started thinking about using the database, and putting the ASP program
The hint information used, and even the URL of the picture, are put into the database and have different fields.

(1) database table design
Table Stringtable
ID int
CH_STR varchar 255
JP_STR varchar 255
EN_STR varchar 255
................... Fields in other languages

(2) INC file Stringtable.inc

Const MAX_STR=100 ' According to the maximum value of ID
Const LANG_CH=1
Const LANG_JP=2
Const LANG_EN=3
Dim Strarr
Dim Strrs
Dim strSQL

If not IsArray (application ("Conststr")) Then
Strsql= "SELECT * from W_stringtable"
Set Strrs=conn.execute (strSQL)
ReDim Strarr (3,MAX_STR)
Do as not strrs.eof
Strarr (LANG_CH,CLNG (Strrs ("ID")) =strrs ("Ch_str")
Strarr (LANG_JP,CLNG (Strrs ("ID")) =strrs ("Jp_str")
Strarr (LANG_EN,CLNG (Strrs ("ID")) =strrs ("En_str")
Strrs.movenext
Loop
Application.Lock
Application ("Conststr") =strarr
Application.UnLock
Strrs.close
Else
Strarr=application ("Conststr")
End If

(3) Application Example
Const LANG_CH,STR_CONFIRM_OVERWRITE=1234
...
Response.Write Strarr (Lang_ch,str_confirm_overwrite)
Response.Write Strarr (Lang_jp,str_confirm_overwrite)

Let's say there's a program user.asp
The method is called as follows
User.asp?language=en (Chinese)
User.asp?language=ch (e-article)

'-----------user.asp
Dim lang
If not (IsNull (Request ("language")) or IsEmpty (Request ("language")) or (Request ("language") = "") Then
If request ("language") = "en" Then
Lang=lang_en
ElseIf request ("language") = "JP" Then
Lang=lang_jp
Else
Lang=lang_ch
End If
Else
Lang=lang_ch
End If
'..................
Response.Write Strarr (Lang,str_confirm_overwrite)

Note:
Meta tag allows you to set the language code for the HTML page.
<meta http-equiv= "Content-type" content= "text/html; Charset=gb_2312-80 "> Chinese gb3212-80
<meta http-equiv</u>= "Content-type" content= "text/html; Charset=x-sjis "> Japanese Shift-jis



Related Article

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.