Internationalization and localization tools


Culture-Sensitive C# Constructor

System.Globalization

public CultureInfo(int culture);

public CultureInfo(string name);

public CultureInfo(int culture, bool useUserOverride);

public CultureInfo(string name, bool useUserOverride);

Internationalization (I18n) Class Overview

The CultureInfo class stores information about a specific culture including the writing system, calendar and language/country descriptions. It also provides access to culture-specific objects that encapsulate the functionality for culture-sensitive operations, such as date, currency and number formatting; character collation and translated resource retrieval.

See Microsoft's MSDN online documentation for more information.

I18n Issues

The constructor signatures for CultureInfo include a variety of argument types that are used to specify the Culture for which this object is to be instantiated. The key here is to ensure that this class is instantiated dynamically according to the culture of the current user and that the culture string or int argument that is passed into the constructor is not hardcoded or set to a default value that might not be correct for all users.

Usage

  1. This constructor takes a pre-defined, Microsoft-specific culture identifier int (LCID) that is mapped to the corresponding National Language Support (NLS) locale identifier.
    public CultureInfo(int LCID)
  2. This constructor takes a string argument that follows the RFC 1766 standard in the format languagecode2-country/regioncode2, where languagecode2 is a lowercase, two-letter code derived from ISO 639-1 and country/regioncode2 is an uppercase, two-letter code derived from ISO 3166. For example, U.S. English is en-US.
    public CultureInfo(string iso_standard_name)
  3. The first argument to this constructor is the LCID, described earlier. The second, boolean argument indicates whether the user wants to override some of the values associated with the specified culture. If set to true, the properties of the DateTimeFormat instance, the NumberFormat instance, and the TextInfo instance are retrieved from the user's Windows settings. This can cause problems when the user-defined settings are incompatible with the specified culture.
    public CultureInfo(int LCID, bool user_override)
  4. This constructor is identical to the previous, except instead of an LCID value to define the culture, the ISO-standard string (described in the second constructor) is used.
    public CultureInfo(int LCID, string iso_standard_name)

Culture and Number Format Information

 

Lingoport internationalization and localization services and software