Getting an Object from a Specific Locale

To get an object from a specific locale, you need to know either the POSIX identifier or the host identifier for that locale. You then create a locale key from that identifier and use the key to instantiate the correct object.

If using POSIX identifiers, you need to specify either the language identifier or both the language and region identifiers. Certain locales also require an extension to distinguish them (for example, Modern and Traditional Spanish Sort).

To get a localized object from a specific locale:

  1. Create an ILocaleKey for the locale and pass in the identifier for it.
  2. Call the localized object class's create function and pass in thekey for the specific locale.

For example, this code shows how to get the collation object for the French Canadian locale:

// Get the collation object for the French Canadian locale

try {

	ICollation *coll = 

		ICollation::createCollation(ILocaleKey("FR", "CA"));

} catch (IException&) {

	// If it isn't available, use the collation for the default 
locale

	coll = ICollation::createCollation();

}


Overview of Locale Classes
Locale Names