Localization in ASP.NET

If you have worked on localization of website you have probably done your fair share of:

  • Setting System.Threading.Thread.CurrentCulture and CurrentUiCulture to the desired CultureInfo, retrieved from Request.UserLanguages
  • Getting the resources from the ResourceManager using GetString and GetObject and adjusting the properties of controls

If not, go read Michelle Leroux's article on MSDN and visit her .NET Dashboard resources site.

Microsoft has also released an Enterprise Localization Toolkit some time ago. This uses a SQL Server database to keep all localized resources from every application in the enterprise. It has really nice ideas, but is a little bloated and particularly unuseful if you do not have SQL Server at your disposal.

I was wondering, since there is not that much that I could find in a Google session and on the popular sites, how you guys and girls do your localization of ASP.NET applications. I would love to hear.

Comments

# Paul Wilson said:

My site (http://www.WilsonDotNet.com) is localized in the following manner:First, I do not use compiled resources for a couple of reasons.  First, web apps often have very dynamic content, so the resources should be updateable on the fly.  That may always be the case, and maybe your content is coming from a database anyhow, but its a frequent case.  Next, the current ASP.NET architecture locks compiled resources, so you can't update them without a restart.  So many of us are using either a database or an xml file to store our resources -- I chose xml for my simple site, although I would choose a database for more complex sites or those that need a nice GUI tool to update the resources.  Either way, the next thing is to cache the strings so you are not hitting the database or the xml file each time.  I do mine on application startup, and put it in a static hashtable for each language, but a larger site could do the caching on first access, maybe for just a part of the app at a time, and maybe the web cache would be better if you need the ability to free it if its not used after a while.  Again, there are lots of design options -- the point is to cache to avoid the database or xml file hit, but do so smartly for your application needs.  Finally, I have a custom label control that allows me or my designers to just set the resource id and have the string automatically pulled, thus not having to use GetString.  I also have an xml sitemap for each locale, and a set of menu controls that handle displaying menus with the proper string resources automatically.  That last one is a sneak peak of ASP.NET v2.0 that I have had working for a year and a half (along with MasterPages), and overall localization will get much easier in v2.0 -- until then mine works well.  I've had managers want to use something other than ASP.NET at two different places because they didn't think it was possible to do this, and all I had to do was show them my existing site.  :)

maandag 7 juni 2004 22:38
# Alex Thissen said:

Thanks for your input, Paul. I hope to comment on this a bit later this week(end).

woensdag 9 juni 2004 22:34