Internationalization of application

The concept:
The process of making application ready for multi-lingual support is called Internationalization of the application. It includes following three steps:
  1. Globalization is the process of designing and developing applications that function for multiple cultures. Thus globalization is a concept which underlines the fact that the application needs to be neutral culture and nothing related to culture is hard coded. The primary task in this phase is to identify the various locale-sensitive resources and to isolate these resources from the executable code. Following are key points to make your application globalized:
    1. Do not hard code cultures like date, currency etc.
    2. Do not hard code texts, put it in resource files.
  2. Localizability: An application that has been globalized must be tested to ensure that its executable code is independent of the culture and language-specific data. This is called localizability testing. The focus of localizability testing is to check how the application adapts itself to different locales
  3. Localization is the process of customizing your application for a given culture and locale. Localization consists primarily of translating the user interface.
Let’s talk now of Implementation:
ASP.NET enables you to create a page that can obtain content and other data based either
  1. On the preferred language setting for the browser or
  2. Based on the user's explicit choice of language.
Content and other data is referred to as resources and such data can be stored in resource files or other sources. In the ASP.NET Web page, you configure controls to get their property values from resources. At run time, the resource expressions are replaced by resources from the appropriate resource file.
Resource files:
Resource files is an XML that contains the string that has to be translated in different languages or paths to images. The resource file contains key/value pairs. Each pair is an individual resource.
Separate resource file has be created either
  1. For each language (hindi & english)
  2. For each language and culture (UK English, US English)
Resource files in ASP.NET have an .resx extension. At run time, the .resx file is compiled into an assembly, which is sometimes referred to as a satellite assembly. Because the .resx files are compiled dynamically, like ASP.NET Web pages, you do not have to create the resource assemblies.
When you create resource files, you start by creating a base .resx file. For each language that you want to support, create a new file that has the same file name. But in the name, include the language or the language and culture (culture name). For example:
  1. WebResources.resx - The base resource file. This is the default (fallback) resource file.
  2. WebResources.en.resx - A resource file for English. This is also called neutral culture file.
  3. WebResources.en-GB.resx - A resource file for english (UK) specifically.
Please note Culture is used to format localize info for non-UI things such as Date, Numbers, Currency, while UICulture is for specifying the locallized UI info (which UI resource set to use), it controls resource loading, translated text and localized control properties like color or font.
Generating resource files:
Resource files in are created on the basis of scope required.
  1. Global resource file - To create global resource file, we have to put resource file in the App_GlobalResources folder at the root of the application. One can read these file from any page or code of the application.
  2. Local resource file - To create local resource file, we may either put files in the reserved folder App_LocalResources or any other folder in the application. You associate a set of resources files with a specific Web page by using the name of the resource file. For example, if there is a file name called index.aspx, :
  1. Index.resx - The base resource file. This is the default (fallback) resource file.
  2. Index.en.resx - A resource file for English. This is also called neutral culture file.
  3. Index.en-GB.resx - A resource file for english (UK) specifically.
You can use any combination of global and local resource files in the Web application. Generally, you add resources to a global resource file when you want to share the resources between pages. However, global resource files can become large, if you store all localized resources in them. Global resource files can also be more difficult to manage, if more than one developer is working on different pages but in a single resource file, in that case local resource is preferable.
Using resource files in Pages:
To use the resource files in the web pages, there are two ways:
  1. Implicit localization - it works with local resources and lets you automatically set control properties to matching resources.
  2. Explicit localization - it lets you use a resource expression to set a control property to a specific resource in a local or global resource file.