Globalization and Localization

Source: Internet
Author: User

Globalization of Windows applications in 20 minutes using C # Rajesh-Lal | 1 Sep 2006 Describes the essential features required to enable multiple programming ages in a Windows application using resource files. Is your email address OK? You are signed up for our newsletters but your email address has not been reconfirmed in a long time. to make this warning go away please click here to have a confirmation email sent so we can confirm your email address and continue sending you your newsletters. alternatively, you can update your subscriptions.
    • Download source files-16.3 KB
Introduction

Globalization and localization are two important processes which every developer shocould be aware of while creating global products or applications. though there are except articles which explain the subject well, I did not find a single resource which explains all important concepts regarding globalization/localization, practically and comprehensively. this article aims to provide practical step-by-step approach to globalizing a web application in ASP. NET 2.0.

Background Theory

globalization is defined as the process of developing a program or an application so that it is usable within SS multiple cultures and regions, irrespective of the language and regional differences. for example, you have made a small inventory management program and you live in a region where English is the main language, assume England. now, if you want to your program in a different country, let's say Germany, then you need to make sure that your program displays and takes input in German language.

localization is the process of creating content, input, and output data, in a region specific culture and language. culture will decide date display settings (like, mm/DD/YYYY or DD/MM/YYYY), currency display formats etc. now, the process by which we can make sure that our program will be localized is known as internationalization or globalization. in simpler terms, globalization can be defined as the set of activities which will ensure that our program will run in regions with different versions and cultures.

So, globalization is related to intrinsic code changes to support such changes like using resource files etc. whereas, localization is the process of using a particle culture and regional info so that the program uses the local versions ages and culture. this means translating strings into a special local language. this covers putting language specific strings in the resource files. globalization starts in the main construction phase along with the code development. localization generally comes later.

Globalizing an ASP. NET 2.0 website

Let's start with a simple example. For the purposes of explaining localization and keeping things simple, I have created a new website in ASP. NET and C #, called Testsite (Source code of the example is wrongly ded in this article). I have added a master page and a default page. This default page has Textbox And Calendar Control. Textbox Control has Double Number which will represent currency, and we will see how the currency format varies as user selects different versions. The default page looks like this when I run the application:

I have published the test web application, and you can see the functional version here.

Cultures and locale

Now, before we move ahead, let me throw some light onCulturesAndLocale.

AGEs also depend upon the geographical location. for example, French is spoken in France as well as Canada (besides extends other countries ). but linguistically speaking, Canadian French is quite different from French spoken in France. similarly, there are linguistic differences between us English and British English. therefore, the language needs to be associated with the participating region where it is spoken, and this is done by usingLocale(Language + location ).

For example: FR Is the code for French language. Fr-fr Means French language in France. So,FR Specifies only the language whereas Fr-fr Is the locale. Similarly, Fr-ca Defines another locale implying French Language and Culture in Canada. If we use only FR , It implies a neutral culture (I. e., location neutral ).

How do we define or change the current culture?

there are two properties of the cultureinfo class in. net FCL (framework class library) which we can set using the overloaded constructor of the class, and then we can use the class to change the culture of the currently executing thread:

    • uiculture : gets/sets the user interface culture for the currently executing thread. this property helps the runtime to load the resource strings from a specific resource file (which we will see later ). this property can take neutral cultures as well as locales. for example:
    • collapse
Thread. currentthread. currentuiculture =NewCultureinfo ("FR ");

Or,

Collapse
 thread. currentthread. currentuiculture =  New  cultureinfo ("FR-ca"); 
  • Culture: Gets/sets the region specific culture and formats of currency, dates etc. This needs language as well as location (locale ).
  • Collapse
    Thread. currentthread. currentculture = New Cultureinfo ("fr-"); //  Correct      /// We have given locale Thread. currentthread. currentculture = New Cultureinfo ("FR "); //  Wrong, Will                                                             //  Not work 

    Sometimes we need a culture which does not belong to any language or locale, Which is invariant of any region/language. For this, we haveCultureinfo. invariantcultureProperty. It is used during the internal system processes which need to be culture independent, or to store data which does not need to be displayed directly to the end user.

    Both Uiculture And Culture Properties can be defined in Web. config File under<Globalization> Property. they can also be specified at page level. but we don't want to hard-code these values, and wocould like to set them dynamically instead. as seen above, we cocould also get/set these values from the code using Thread. currentthread. currentculture And Thread. currentthread. currentuiculture Properties. So, we will use these properties in our application.

    Switching locale

    coming back to our application, we need a way to switch the locale. there are two approaches regarding this:

    1. Use the browser settings:In ie, the user can change the culture by goingInternet Options-> General-> ages. For this to work, we need to set bothCultureAndUicultureToAutoAndEnableclientbasedculture = trueAs:
    2. Collapse
      <  Globalization   Culture  ="  Auto"   Uiculture  ="  Auto"   Enableclientbasedculture  ="  "True ""   / > 
    3. User specified settings:We can give an option for the user to specify and change the culture and the language at runtime. this is the recommended approach, as sometimes the browser itself may not have the user specific culture set (for example, a French tourist might be surfing Net in India ). also, sometimes changingLanguageSettings via the browser is blocked.

    Going by the second recommended approach, I have created a section on the top (insidePanelControl) in the master page where I have a drop-down with these language options which let the users choose a particle locale. for registration purposes, I have the option of only four versions ages to choose from: Hindi, US English, British English, and French.

    For my application to be globalized, I want that whenever the user selects a locale from the language, the following shoshould happen:

      1. all content shoshould be localized: this means that all strings and text shoshould be displayed in the chosen language and locale.
      2. each control's caption/content shoshould also show text in local language.
      3. date and currency formatting shoshould occur according to the chosen locale.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.