Pages

Men

rh

4/26/2013

Globalization in Asp[1].net

1. Introduction:
In past, the term localization often referred to a process that began after an application developer compiled the source files in the original language. Whereas in pre-Internet days it wasn't unusual for an application to be designed for use in a single country, now an Internet application can be accessed by users from anywhere in the world. Another team then began the process of reworking the source files to use in another language. The original language, for example, might be English, and the second language might be German. That approach, however, is prohibitively expensive and results in inconsistencies among versions. It has even caused some customers to purchase the original-language version instead of waiting months for the localized version.

Localization is the process of making an application runs in multiple locations. It has to support specific set of formatting rules for things like numbers, dates sorting rules and so on and a specific languages that text need to be translated too. For this Microsoft visual studio .Net 2.0 environment has expanded the developers tool box , added new runtime capabilities and providing a rich new programming API specifically targeting localization requirements. This helps a lot to the developers when they are developing an application for the World Wide Web.

Using the localization concept developers will be able to separate the localizable content from their Asp.net pages; by doing this the re-engineering effort for localization has been reduced and the localization feature can be provided to the application with minimal effort. If the Application is ready with the Globalization then n-number of Localizable languages can be implemented to the application.

2. Definitions

Globalization
Globalization is the identification of all the localizable resources in the application and separating them from the executable code so that they can be modified easily.

Localizability
Localizability is checking whether the changes needed for a given location will require design changes to the application.

Localization
Localization is the actual customization of the application for the designated locales consisting primarily of translating resources that developers identified during the globalization phase.

Culture
Culture is used to determine culture dependent function such as Date, Currency etc.

UICulture
This property supports by the .NET Framework and it helps the runtime to load the resource strings for the corresponding UI component from a defined resource file.

Resource File
Resource File contains resource strings and each string will be assigned to a value depending upon the Culture and Localization.

Globalization:
Globalization=Internationalization + N * Localization.

There will be two processes in Globalization and they are customization or localization of the application and internationalizing the application codes so as to meet the standards of the local culture and other related matters.

The Internationalization process makes it possible to translate, Store, retrieve and present application content for any locale, preferably using the same application code base.

Locale is the combination of both language and culture environment, including the format of dates, time, currencies, telephone numbers, and so on. This implies isolating locale-dependent from locale-independent content and also preparing code to dynamically format that content according to locale. The end result of application Internationalization supports its localization. This localization process should be relatively painless for the development team if internationalization was part of the initial development cycle. Completed

4. Internationalization:
“Internationalization of the software is a thought that needs to be applied at the beginning of development of the software rather than a late addition.”

The ideal goals of internationalization are to:

Remove all contents from the presentation layer and form the code base. The idea is to have a single code base and single presentation layout that will present content for any culture.

Place content in the location that can be easily translated and that will be programmatically accessible to populate the presentation layer.

Store content and user input in a format that can be presented with integrity for the appropriate culture.

Internationalization is the process of designing an application so that I can be adapted to
Various languages and regions without engineering changes. Software internationalization is the development process using libraries that enable one single application to work with text in all languages, for any place in the world, instead of having software versions for five different countries; you can use a frame work to create one version that can work impeccably and transparently in many different and unique countries. Internationalization is commonly referred as I18n (“I18n”, it is a standard abbreviation for Internationalization “, which starts with the letter I, ends with the letter N, and contains a total of 18 letters).

Characteristics of Internationalization:

With the addition of localized data, the same executable can run world wide.
Support for new language does not require recompilation.
Culturally dependent data, such as dates and currencies, appear in formats that conform to the end user’s region and language.
It can be localized quickly.

5. Localization:
Localization is the actual customization of the application for the designated locales consisting primarily of translating resources that you identified during the globalization phase.

Localization means adapting your application to other locales by translating and formatting content according to culture, hopefully without touching the code. Localization is commonly referred as L10n (“L10n”, it is a standard abbreviation for Localization “, which starts with the letter L, ends with the letter N, and contains a total of 10 letters).

Following these steps, the localization process for a particular culture would include:
Translation of all content by a third party. How easy this is depends largely on where content is stored and how tightly integrated it is with other parts of the application.

Integration of translated content with the application. If not tightly coupled to the presentation layer or code base, this should have minimal impact on developers and user interface designers.

What will be typically be localized?
The obvious item is that any text should be translated; others are:
Form layouts: Some languages will simply occupy more space than others on average
Display formats: Dates, times, currency, numbers
Data input fields: e.g. zip codes (US) versus post codes (UK)
Graphics with local content, e.g. maps
Shortcut keys
Calendars
Alphabetical order

Localization (L10N) is the process of adapting software for a specific region or language by adding locale-specific components and translating text. Usually, the most time-consuming portion of the localization phase is the translation of text.

An internationalized application can display information differently throughout the world. For example, the program will display different messages in Paris, Tokyo, and New York. If the localization process has been fine-tuned, the application will display different messages in New York and London to account for the differences between American and British English. Text messages are the most obvious form of data that varies with culture. However, other types of data may vary with region or language. The following list contains examples of culturally dependent data:

- Messages Labels - Online help - Sounds
- Colors - Graphics Icons - Dates
- Times - Numbers - Currencies
- Measurements - Phone numbers - Honorific and personal titles
- Postal addresses - Page layouts

Globalization Best Practices for ASP.NET Applications:
1. Explicitly set the CurrentUIculture and CurrentCulture properties in your application. Do not rely on defaults.

2. Note that ASP.NET applications are managed applications and therefore can use the same classes as other managed applications for retrieving, displaying, and manipulating information based on culture.

3. Be aware that you can specify the following three types of encodings in ASP.NET:
requestEncoding specifies the encoding received from the client's browser.
responseEncoding specifies the encoding to send to the client browser. In most situations, this should be the same as requestEncoding.
fileEncoding specifies the default encoding for .aspx, .asmx, and .asax file parsing.

4. Specify the values for the requestEncoding, responseEncoding, fileEncoding, culture, and uiCulture attributes in the following three places in an ASP.NET application:
In the globalization section of a Web.config file. This file is external to the ASP.NET application. For more information, see Element.
 
In a page directive. Note that when an application is in a page, the file has already been read. Therefore, it is too late to specify fileEncoding and requestEncoding. Only uiCulture, Culture, and responseEncoding can be specified in a page directive.
 Programmatically in application code. This setting can vary per request. As with a page directive, by the time the application's code is reached it is too late to specify fileEncoding and requestEncoding. Only uiCulture, Culture, and responseEncoding can be specified in application code.

5. Note that the uiCulture can be set to the browser accept language.




6. Globalizing Applications:

Globalization is the process of designing and developing a software product that functions for multiple cultures. This section applies to both Windows Forms and Web Forms pages.

Culture-Specific Classes for Global Windows Forms and Web Forms:

Each culture has different conventions for displaying dates, time, numbers, currency, and other information. The System.Globalization namespace contains classes that can be used to modify how culture-specific values are displayed, such as DateTimeFormatInfo, Calendar, and NumberFormatInfo.

Using the Culture Setting:
But most of the time you will use the culture setting, stored either in the application or in the Regional Options control panel, to automatically determine the conventions at run time and format the information accordingly.
How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization:
In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page. The two culture settings do not have to have the same value. Depending on your application, it might be important to set them separately.
To set the Culture and UI culture for an ASP.NET Web page declaratively
To set the UI culture and culture for all pages, add a globalization section to the Web.config file, and then set the UIculture and culture attributes, as shown in the following example:

To set the UI culture and culture for an individual page, set the Culture and UICulture attributes of the @ Page directive, as shown in the following example:

To have ASP.NET set the UI culture and culture to the first language that is specified in the current browser settings, set UICulture and Culture to auto. Alternatively, you can set this value to auto: culture_info_name, where culture_info_name is a culture name. For a list of culture names, see CultureInfo. You can make this setting either in the @ Page directive or Web.config file.


To set the culture and UI culture for an ASP.NET Web page programmatically:
Override the Initialize Culture method for the page.
 
Initialize Culture:
The Initialize Culture method is called very early in the page life cycle, before controls are created or properties are set for the page. Therefore, to read values that are passed to the page from controls, you must get them directly from the request using the Form collection.
In the overridden method, determine which language and culture to set the page to.
 
Set the UI culture and culture in one of the following ways:
• Set the Culture and UICulture properties of the page to the language and culture string (for example, en-US). These properties are internal to the page, and can only be used in a page.
• Set the CurretnUICulture and CurrentCulture properties of the current thread to the UI culture and culture, respectively. The CurrentUICulture property takes a language and culture information string. To set the CurrentCulture property, you create an instance of the CultureInfo class and call its Create specific culture method.

The following code example shows an ASP.NET Web page that lets users select their preferred language from a drop-down list. The page imports two namespaces to make it more convenient to work with threading and globalization classes.

English
EspaƱol
Deutsch
French
Arabic - Algeria
Classes that automatically format information according to the culture setting are called culture-specific. Some culture-specific methods are IFormattable..:: .ToString, Consoole..:: .WriteLinte and String..:: .Format. For example, the following code shows how you can use the ToString method to format currency for the current culture:

// Put the using statements at the beginning of the code module
Using System.Threading;
Using System.Globalization;
// Display a number with the culture-specific currency formatting
int myInt = 100;
Console.WriteLine(myInt.ToString("C",Thread.CurrentThread.CurrentCulture));
If the culture is set to "fr-FR", you will see this in the output window:
100,00
If the culture is set to "en-US", you will see this in the output window:
$100.00

No comments :

Post a Comment