Localization and globalization in c#


Published on

Published in: Technology, Business
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Localization and globalization in c#

  1. 1.  Localization is the process of customizing your application for a given culture and locale.  Globalization is the process of designing and developing applications for multiple cultures.
  2. 2.       Languages depend upon the geographical location. For eg: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).
  3. 3. Culture & UICulture •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: Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr”); Or, Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr-CA”);
  4. 4. • Culture: gets/sets the region specific culture and formats of currency, dates etc. •This needs language as well as location (locale). Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr-CA”); //correct as we have given locale Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr”); //wrong, will not work
  5. 5. Switching Locale •Use the browser settings: In IE, the user can change the culture by going to Internet Options->General->Languages. For this to work, we need to set both the Culture and the UICulture to auto and enableClientBasedCulture = true as: <GLOBALIZATION culture="auto" uiculture="auto" enableClientBasedCulture="”true”" /> •User specified settings: We can give an option for the user to specify and change the culture and the language at
  6. 6. Resource File •A resource file is a XML file that contains the strings that we want to a. Translate into different languages. b. Can be updated dynamically so that user themselves can modify values in resource files once the application is deployed on the server without re-compiling the entire application itself. •The resource file contains key / value pairs. •Each pair is an individual resource.
  7. 7. Local resource is specific to a single web page and used for providing versions of a Web page in different languages.  resources must be stored in App_LocalResources sub folder. 
  8. 8. Global resource can be read from any page or code that is in the application.  Global resource must be stored in App_GlobalResources sub folder. 
  9. 9.  LocalResources folder contains resources which apply for one page or user control only.  While resources in GlobalResources are accessible in the whole application.
  10. 10.  Design a fairly simple webpage with a few label controls and a button control  Tools Generate Local Resource This will create a corresponding Default.aspx.resx resource file for your webpage in the App_LocalResources folder.  Note: Controls removed from the page will still show up in the resource file. Make sure to clean the resource file if you have
  11. 11. •The attribute meta:resourcekey was added to your controls. •The attribute value corresponds to the resource file control names (e.g. meta:resourcekey="Label1Resource1" corresponds to "Label1Resource1" and all its properties in the Default.aspx.resx file). <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" culture="es-MX" meta:resourcekey="PageResource1" uiculture="es" %>