Thursday, July 08, 2010

Internationalizing Web Apps uing Global Resource

For a web app to support multiple language, (for asp.net) you go to use them (.RESX) files. (or you could invent your own custom method, but im not those type of people) so anyways, here's how it work.

1. Create a 'ASPNET Folder' => 'App_GlobalResources'

2. Add a 'Resource file' in that folder and name it
  • ResourceDefault.resx
3. Double-click on it, in the 'Name' Field, type something to describe it (e.g 'submitButton')
Next in the Value field, type the text that will appear for that control (e.g 'Submit')

4. Repeat steps (2-3) except the new resource filename should be
  • ResourceDefault.ms.resx
if (the language is 'Malay') else name the middle extension as the language you are supporting for. For a complete list of Languages or rather 'Middle Extensions that you can use' See this URL:- CultureInfo (System.Globalization)


Basically for ASIA
  • ms (malay)
  • ms-BN (malay brunei)
  • ms-MY (malay - Malaysia)
  • hi (hindi)
  • id (indonesia)
  • ja (japanese)
  • ur (urdu)
  • th (thai)
  • ar (arabic)
  • zh-SG - chinese singapore
  • ko (korean)
5) Next you need to update your control Text label
e.g:
 <asp:Label ID="lblTitle" runat="server" Text="<%$ Resources:ResourceDefault,Title %>"></asp:Label>
and at the page Header, add:-=
<%@ Page Language="C#" AutoEventWireup="true" UICulture="ms" CodeFile="Default.aspx.cs" Inherits="SampleApp_Default" %>

where my resource filename is : ResourceDefault.ms.resx

Tutorial Links
1. ASP.NET QuickStart Guide for 'Internationalizing Your Apps'
2. MSDN: How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization
3. ASP.NET Web Page Resources Overview
4. Resources in .Resx File Format

No comments: