Using locales for foreign international and numbers
Using locales for international dates and numbers
By Michiel van Otegem
12 December 2000
For many international users the American dates, number notations, money notations, etc. that ASP uses by default
are of little use. Fortunately ASP enables you to change the locale, so you can use dates and numbers in notations
used in a certain country or region. Per ASP version it differs however how easy and flexible this is.
In ASP 1.0 the server has to be adjusted to the right 'locale' via the Control Panel.
The steps below do this with Dutch as example:
- Open Regional Settings in the Control Panel
- Put the drop-down on 'Dutch (Standard)' or 'Dutch (Belgian)'
- Select 'Set as system default locale'
- Click on OK
- Install the Dutch files and restart if necessary
The entire system is set to Dutch now and this could cause some surprises,
especially when you use code from someone else. In addition all programs on the server
now work with this setting.
In ASP 2.0 you can change the locale during run-time with
<%Session.LCID = 1043%>, you can even do this multiple times in
a page (see test-script below). The drawback of this method is that it doesn't work
when the Session object isn't available, because Session support is switched off
(in the entire website, or on that page). Note that on Windows NT 4.0 you may have to install the language files
for different locales. On Windows 2000 this is no longer necessary.
In ASP 3.0 you can state on top of the page which locale has to be used
for that page. You can do this by putting <%@ LCID=1043%> (for Belgium 2067)
on top of the page.
In ASP 2.0 you can also put this code at the top of the page without getting an error message,
but this doesn't change the result.
The script below shows what happens when you change the locale with the Session object. You can also
see if this site runs on ASP 2.0 or ASP 3.0. In the last case the first two commands
should give the same result as the one after that. Otherwise they state the American values.
locale.asp
<%@ LCID=1043%>
<%
Response.Write(FormatCurrency(1000) & "<br>")
Response.Write(FormatDateTime(Now(), 1) & "<br>")
Session.LCID = 1043
Response.Write(FormatCurrency(1000) & "<br>")
Response.Write(FormatDateTime(Now(), 1) & "<br>")
Session.LCID = 2067
Response.Write(FormatCurrency(1000) & "<br>")
Response.Write(FormatDateTime(Now(), 1) & "<br>")
%>
|