Thursday, January 19, 2006

Wicked Code 2.0 -- (feature 3/5)

Feature 3: Auto Culture Handling

PROBLEM: How do we handle localization in our web sites...?

Let's look first at ASP .net 1.x:-

void Application_BeginRequest (Object sender, EventArgs e)
if (Request.UserLanguages.Length > 0)
CultureInfo ci = CultureInfo.CreateSpecificCulture(
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;
catch (ArgumentException)
// Do nothing if CreateSpecificCulture fails
} 2.0 (almost no code....) [Auto culture]:-

<%@ Page Culture="auto" UICulture="auto" Language="C#" CompileWith="AutoCulture.aspx.cs" ClassName="AutoCulture_aspx" %>

Obviously, there's more to localizing an entire Web site than simply enabling auto-culture handling. Auto-culture handling does not, for example, localize static Web site content. But ASP.NET 2.0 offers other new localization features as well, including the new tag for localizing static content and $ Resources expressions for loading localization resources declaratively.

No comments: