Module: Internationalization Module Group: Localization
Does Not Inherit
#include <rw/i18n/RWULocale.h>
An RWULocale identifies a specific language, country, and variant. Services in the Internationalization Module that are sensitive to the locale of the user accept an RWULocale to tailor the behavior of the service.
RWULocale does not directly map to RWLocale in the Essential Tools Module of SourcePro Code, to POSIX locale, or to std::locale. RWULocale stringently defines the language, country and variant codes, unlike the less clearly specified names allowed by these other representations. The locale name associated with an RWULocale is composed of an ISO-639 language code, an ISO-3166 country code, and a platform-specific variant, separated by underscores. The variant name may be compound, composed of more than one variant, joined by underbars. A locale name need not contain all of these components--for example, es, es_ES, es__TRADITIONAL and es_ES_TRADITIONAL are all valid locale names.
The ISO standards are owned by the International Organization for Standardization. You may purchase copies of ISO-639 or ISO-3166 via their web site:
However, as of this writing, the same lists are available without charge. For a list of possible ISO-639 language codes, by the official ISO maintainer, see:
http://lcweb.loc.gov/standards/iso639-2/iso639jac.html
For a list of possible country codes, by the official ISO maintainer, see:
http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html
Another good resource is Robin Cover's XML "Cover Pages":
http://xml.coverpages.org/iso639-en-20000425.html
http://xml.coverpages.org/country3166.html
RWULocale does not directly provide formatting services, as do the SourcePro and standard C++ locale classes. Instead, RWULocale is used to index into the rich set of services provided by the Internationalization Module. For example, an RWULocale instance may be used to retrieve locale-dependent data from an RWUResourceBundle, or to take language-specific conventions into account when collating strings using an RWUCollator.
Because an RWULocale provides nothing more than simple locale identification, no validity checking is performed when you specify an RWULocale or one of its parts. To check the valid locale names, use RWUAvailableLocaleList to construct an iterator that references the const list of locale names currently recognized by the Internationalization Module.
RWUAvailableLocaleList, RWUAvailableLocaleListIterator, RWUResourceBundle
static RWULocale getDefault();
Returns the default RWULocale. The initial default is set at startup time to some system-specific value.
static void setDefault(const RWULocale& newDefault);
Sets the value of the default RWULocale to newDefault.
RWULocale();
Default constructor. Creates an empty locale that may later be assigned to using operator=().
NOTE -- Do not use an empty locale to key into locale-specific behavior.
RWULocale(const RWCString& fullName);
Constructs an RWULocale from the character string fullname describing the locale. The string must be composed of an ISO-639 language code, an ISO-3166 country code, and a platform-specific variant, separated by underscores. The variant name may be compound, composed of two variants joined by an underbar. A locale name need not contain all of these components--for example, es, es_ES, es__TRADITIONAL, and es_ES_TRADITIONAL are all valid locale names.
NOTE -- Passing an empty string does not create an empty RWULocale, but instead creates a copy of the current default RWULocale. See also getDefault() and setDefault().
RWULocale(const char* fullName);
Constructs an RWULocale from the character string fullname describing the locale. The string must be composed of an ISO-639 language code, an ISO-3166 country code, and a platform-specific variant, separated by underscores. The variant name may be compound, composed of two or more variants joined by an underbar. A locale name need not contain all of these components--for example, es, es_ES, es__TRADITIONAL, and es_ES_TRADITIONAL are all valid locale names.
NOTE -- Passing an empty string or null pointer does not create an empty RWULocale, but instead creates a copy of the current default RWULocale. See also getDefault() and setDefault().
RWULocale(const char* language, const char* country, const char* variant=0);
Constructs an RWULocale from language, country, and variant character strings. Use a null pointer to indicate an absent part.
The language string is a lowercase two- or three-character ISO-639 code that names the language of the RWULocale. The country string is an uppercase two-character ISO-3166 code that names the country of the RWULocale. The variant string is an uppercase system-specific code that specifies, in a system-defined way, some variant of the language and country. For example, MAC for Macintosh, POSIX for POSIX, or TRADITIONAL for a traditional variant. Where two or more variants apply, put the more important first, appending the others with an underbar between. The default variant is the empty string.
RWULocale& operator=(const RWULocale& other);
Assignment operator. Replaces self with other.
bool operator==(const RWULocale& other) const;
Returns true if RWULocale other has the same name as self; otherwise, false.
bool operator!=(const RWULocale& other) const;
Returns true if RWULocale other does not have the same name as self; otherwise, false.
RWCString getCountry() const;
Returns self's ISO-3166 country code (two characters).
RWUString getDisplayCountry(const RWULocale& inLocale = RWULocale::getDefault()) const;
Returns the display country name according to the given RWULocale inLocale. If no locale is supplied, returns the display country name according to the default locale.
RWUString getDisplayLanguage(const RWULocale& inLocale = RWULocale::getDefault()) const;
Returns the display language name according to the given RWULocale inLocale. If no locale is supplied, returns the display language name according to the default locale.
RWUString getDisplayName(const RWULocale& inLocale = RWULocale::getDefault()) const;
Returns the display name according to the given RWULocale inLocale. If no locale is supplied, returns the display name according to the default locale.
RWUString getDisplayVariant(const RWULocale& inLocale = RWULocale::getDefault()) const;
Returns the display variant code name according to the given RWULocale inLocale. If no locale is supplied, returns the display variant code name according to the default locale.
const RWCString getIso3Country() const;
Returns self's country code. See ISO-3166.
const RWCString getIso3Language() const;
Returns self's language code. See ISO draft standard ISO-639-2 (more than two characters).
RWCString getLanguage() const;
Returns self's ISO-639 language code (two characters).
uint32_t getLCID() const;
Returns the Windows LCID value of self. Returns 0 in case of missing resource, wrong format, or non-Windows operating system.
RWCString getName() const;
Returns self's name, consisting of the language, country and variant codes, each part optional. If there is more than one part, then underbars join the parts. In the case of a name consisting of the language and the variant, with no country code, two adjacent underbars are present.
RWCString getVariant() const;
Returns self's variant (not per any standard).
uint32_t hash() const;
Returns a hash code for self.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.