Creating a Multilingual Web Site
by Darius Hurdle
In Canada and other multilingual countries such as the USA a lot of sites have to support English and French at the very least. Most sites have a clumsy design where the user is asked on the first page to select a language (and to add to the frustration, these introductory "language selection" pages often are too heavy on the graphics. So here is a small piece of code which you should save in a file as default.asp. Do not insert any regular html code in this snippet - you will get an error. You can of course add as much ASP code as you like:
<% 'Detects language and redirects to the appropriate page
strFullLang = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
x=instr(strFullLang,"-")
If x <= 1 Then
strLang = strFullLang
Else
strLang = Left(strFullLang, x-1)
End If
strLang = LCase(Trim(strLang))
Select Case strLang
Case "fr"
Response.Redirect "francais.html"
Case Else
Response.Redirect "english.html"
End Select%>
On your pages, you should still provide a mechanism so that people can select a different language.
You may add other languages just by adding new "cases". A list of language codes can be found at: http://www.w3.org/International/O-charset-lang.html
Note that all the funny stuff at the top of the routine was just to handle all possible values for HTTP_ACCEPT_LANGUAGE (such as fr, en-us, en-gb or eskimo...).
Even if you don't use several languages on your web site, it is probable a good idea to have some sort of "redirecting" page anyway. That way you don't have to worry as much about overwriting one default.asp file with another default.asp file.