|
When writing applications for international distribution, different cultures and regions must be kept in mind. Different cultures have diverging calendars and use different number and date formats, and also the sort order with the letters A-Z may lead to various results. To make applications fit for global markets you have to globalize and localize them.
- Globalization is about internationalizing applications: preparing applications for international markets. With globalization, the application supports number and date formats depending on the culture, different calendars, and so on.
- Localization is about translating applications for specific cultures. For translations of strings, you can use resources.
.NET supports globalization and localization of Windows and Web applications. To globalize an application you can use classes from the namespace System.GlobalizationSystem.Resources. whereas to localize an application you can use resources that are supported by the namespace
System.Globalization
The System.Globalization namespace holds all culture and region classes to support different date formats, different number formats, and even different calendars that are represented in classes such as Gregorian calendar, Hebrew Calendar, Japanese Calendar, and so on. Using these classes you can display different representations depending on the user's locale.
Cultures and Regions
The world is divided into multiple cultures and regions, and applications have to be aware of these cultural and regional differences. RFC 1766 defines culture names that are used worldwide depending on a language and a country or region. Some examples are en-AU, en-CA, en-GB, and en-US for the English language in Australia , Canada , United Kingdom , and the United States .
Note:- Most Important class in System.Globaliation namespace is CultureInfo [Represents a Culture]
Example: Demonstrate CultureInfo
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Threading;
using System.Globalization;
namespace ConsoleApplication1
{
class Program1
{
static void Main ( string [] args)
{
int val = 1234567890;
string name = "visualbuilder" ;
Console .WriteLine(val.ToString( "N" ));
Console .WriteLine(val.ToString( "N" , new CultureInfo ( "fr- FR" )));
Thread .CurrentThread.CurrentCulture = new CultureInfo ( "de- DE" );
Console .WriteLine(val.ToString( "N" ));
}
}
}
Output:
The following output will be displayed on console.
Display in Current Culture: 1,234,567,890.00
Display in French Culture: 1 234 567 890, 00
Display in DE Culture: 1.234.567.890, 00
|