ASP.NET Globalization and Localization

Posted: January 4, 2011 in ASP.NET, Web Development
Tags:

Globalization is the process of designing and developing applications that function for multiple cultures.

  1. .NET Framework resource manager is used by ASP.NET at run time to retrieve the culture-appropriate resource for each resource in the default resource file
  2. Localization is the process of customizing your application for a given culture and locale. Localization consists primarily of translating the user interface using resource files. Resource File Types …
    • Global Resource Files – present in App_GlobalResources folder in app root level. Naming for global resource files – name.language.resx, name.language-culture.resx – used across pages
    • Local Resource Files – present in App_LocalResources Folder at any level. Naming for local resource files – pageOrControlName.extension.language.resx, pageOrControlName.extension.language-culture.resx – used for specfic page
  3. Use Resources to Set Property Values in Web Server Controls 
    • Implicit localization – <asp:Button ID=”Button1″ runat=”server” Text=”DefaultText”  meta:resourcekey=”Button1″ />
    • Explicit localization – <asp:Button ID=”Button1″ runat=”server” Text=”<%$ Resources:WebResources, Button1Caption %>” />
  4. To retrieve resource values programmatically (These overloaded methods are available in the HttpContext and TemplateControl classes)
    • GetLocalResourceObject(“Button1.Text”) – read resources from local resource file
    • GetGlobalResourceObject(“WebResourcesGlobal”, “LogoUrl”) – read resources from global resource file
  5. Retrieve global resources using strong typing – Resources.Class.Resource
  6. To set the culture and UI culture for an ASP.NET Web page declaratively
    • for all pages – <globalization uiCulture=”es” culture=”es-MX” />
    • individual page – <%@ Page UICulture=”es” Culture=”es-MX” %>
  7. To set the culture and UI culture in C#
    • Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(“en-US”);
    • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“en”);
  8. Use fiddler to access website/page to check the local view in different country or local view of other country
  9. Follow HTML Layout guidelines for web page globalization – like avoiding absolute positions, utilizing max available width/height, allow wrapping, don’t use fixed size … etc

References

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s