Fog Creek Software
Discussion Board




Localisation of ASP on IIS via VB Components

Is anyone aware of any formatting APIs that accept Locale ID? We need to be able to format values into a parameterised locale instead of the system default.

Background...
Our company has an ASP solution that calls Visual Basic COM+ Components.

We have to produce an dual-language solution.

We had the presence of mind to pass all date/number/currency formatting through a common functions implemented in system components.

All the API formatting methods I am aware of do not accept the LCID as a parameter; instead they use the current system LCID.

Tim H
Friday, September 12, 2003

You could start with the API functions:
GetLocaleInfo
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_34rz.asp

GetDateFormat: The GetDateFormat function formats a date as a date string for a specified locale. The function formats either a specified date or the local system date.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_5w6s.asp

GetTimeFormat: The GetTimeFormat function formats time as a time string for a specified locale. The function formats either a specified time or the local system time.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_6at0.asp

GetNumberFormat: The GetNumberFormat function formats a number string as a number string customized for a specified locale.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_8a0k.asp

GetCurrencyFormat: The GetCurrencyFormat function formats a number string as a currency string for a specified locale.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_0rec.asp

Philip Dickerson
Friday, September 12, 2003

All of the functions listed in my previous post accept the Locale (in LCID format) as a parameter.

Philip Dickerson
Friday, September 12, 2003

That's really valuable!
Thanks Philip!

Does anyone have any neat ASP localisation tricks?

Tim H
Friday, September 12, 2003

I seem to remember that the locale in effect in an ASP page is, by default, the locale of the >web browser<, strange as that sounds, and you can change it at runtime with setLocale.

We have all this stuff working in FogBUGZ somewhere. The book Internationalization with Visual Basic was invaluable.

Joel Spolsky
Friday, September 12, 2003

If your team wants to move to .NET eventually, I'd strongly recommend porting your app now to ASP.NET and VB.NET. 

You can easily link into those existing COM objects (and optionally rebuild them as .NET assemblies when you want to), and the .NET framework has some good Localization classes that might make your job much easier; automatic, even, in some cases. 

Check out the four pages in the 'Localization' section here for examples: http://www.asp.net/Tutorials/quickstart.aspx

Gary Pupurs
Sunday, September 14, 2003

*  Recent Topics

*  Fog Creek Home