SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Defines a specific language, country, and variant. More...
#include <rw/i18n/RWULocale.h>
Public Member Functions | |
RWULocale () | |
RWULocale (const RWCString &fullName) | |
RWULocale (const RWULocale &other) | |
RWULocale (const char *fullName) | |
RWULocale (const char *language, const char *country, const char *variant=0) | |
RWCString | getCountry () const |
RWUString | getDisplayCountry (const RWULocale &inLocale=RWULocale::getDefault()) const |
RWUString | getDisplayLanguage (const RWULocale &inLocale=RWULocale::getDefault()) const |
RWUString | getDisplayName (const RWULocale &inLocale=RWULocale::getDefault()) const |
RWUString | getDisplayVariant (const RWULocale &inLocale=RWULocale::getDefault()) const |
const RWCString | getIso3Country () const |
const RWCString | getIso3Language () const |
RWCString | getLanguage () const |
uint32_t | getLCID () const |
RWCString | getName () const |
RWCString | getVariant () const |
uint32_t | hash () const |
bool | operator!= (const RWULocale &other) const |
RWULocale & | operator= (const RWULocale &other) |
bool | operator== (const RWULocale &other) const |
Static Public Member Functions | |
static RWULocale | getDefault () |
static void | setDefault (const RWULocale &newDefault) |
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/home/standards/country_codes.htm
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.
|
inline |
Default constructor. Creates an empty locale that may later be assigned to using operator=().
|
inline |
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.
|
inline |
Constructs an RWULocale that is a copy of other.
RWULocale::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.
|
inline |
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.
|
inline |
Returns self's ISO-3166 country code (two characters).
|
inlinestatic |
Returns the default RWULocale. The initial default is set at startup time to some system-specific value.
RWUString RWULocale::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 RWULocale::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 RWULocale::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 RWULocale::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.
|
inline |
Returns self's country code. See ISO-3166.
|
inline |
Returns self's language code. See ISO draft standard ISO-639-2 (more than two characters).
|
inline |
Returns self's ISO-639 language code (two characters).
|
inline |
Returns the Windows LCID value of self. Returns 0
in case of missing resource, wrong format, or non-Windows operating system.
|
inline |
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.
|
inline |
Returns self's variant (not per any standard).
|
inline |
Returns a hash code for self.
|
inline |
Returns true
if RWULocale other does not have the same name as self; otherwise, false
.
Assignment operator. Replaces self with other.
|
inline |
Returns true
if RWULocale other has the same name as self; otherwise, false
.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |