.NET Internationalization Programming
Culture & Region

The basic point of .NET Internationalization Programming is CultureInfo class and RegionInfo class, especially the former. The all of .NET APIs support internationalization function and provide some culture specific utilities under the CultureInfo class settings.

CultureInfo and RegionInfo class should be created aware of OS setting locale or user specific one, with no hardcoded language and country.

*** These codes are not recommended.

CultureInfo myCIintl = new CultureInfo( "es-ES"); <- *created by the hardcoded name
CultureInfo myCIintl = new CultureInfo(0x0409); <- *created by the hardcoded LCID

RegionInfo myRI1 = new RegionInfo("US"); <- *created by the hardcoded name
RegionInfo myRI2 = new RegionInfo(0x0409); <- *created by the hardcoded LCID

Like the other programming language (e.g. Java), you have to care about the functionalities affected by locale (called 'culture' in .NET).
Some of the important classes and methods are listed below.
------------------------------------------------------------------------------------------------
Important classes and methods
------------------------------------------------------------------------------------------------
*DateTimeFormatInfo               
    Format date and time
    
*NumberFormatInfo                 
   Format numbers and currencies

*String.ToUpper/ToLower                   
   Make strings uppercase/lowercase
   
*String.Compare/CompareTo/CompareOrdinal                 
   Compare the strings
   
*Array.Sort                       
   Sort data

*DateTime.ToString      
   Format the date and time string with given format character.
   ("d", "D", "f", "F", ...etc)
                                 
   The culture specific format (e.g. "yyyy/mm/dd") should not be used. 
                                 
   The following methods are corresponding to the each format character, 
   but using ToSting is recommended because it can handle more formats.
   
   *ToShortDateString
   *ToLongDateString
   *ToShortTimeString
   *ToLongTimeString

The following are culture specific classes about calendar.

*GregorianCalendar   
            
*HebrewCalendar

*HijiriCalendar

*JapaneseCalendar

*JulianCalendar

*koreanCalendar

*PersianCalendar

*TaiwanCalendar

*ThaiBuddhistCalendar

*ChineseLunisolarCalendar

*JapaneseLunisolarCalendar

*KoreanLunisolarCalendar

*ThaiwanLunisolarCalendar

*JalaaliCalendar

*UmAlQuraCalendar

You can get the current culture and the current UI-culture in the following steps.

System.Globalization.CultureInfo curCi=
   System.Globalization.CultureInfo.CurrentCulture;
System.Globalization.CultureInfo curUICi=
   System.Globalization.CultureInfo.CurrentUICulture; 
CurrentCulture is a culture used by the current thread, and CurrentUICulture is a culture used by ResourceManager to refer to resources when the application is running.

For more details of .NET specification, refer to the MSDN.

Go to Internationalization Programming Top


Copyright (C) 2012 Kokusaika JP, Inc.
All rights reserved. No reproduction or republication without written permission.