Internationalization and localization tools


Culture-Sensitive VB.NET Constructor

System.Globalization

Public Sub New(culture As Integer)
Public Sub New(name As String)

Public Sub New(culture As Integer, useUserOverride As Boolean)

Public Sub New(name As String, useUserOverride As Boolean)

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.
    Dim culture As Integer

    Dim instance As New CultureInfo(culture)
  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.
    Dim iso_standard_name As String

    Dim instance As New CultureInfo(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.
    Dim LCID As Integer
    Dim user_override As Boolean

    Dim instance As New CultureInfo(LCID, 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.
    Dim iso_standard_name As String
    Dim user_override As Boolean

    Dim instance As New CultureInfo(iso_standard_name, user_override)

Culture and Number Format Information

 

Lingoport internationalization and localization services and software