rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWULocale Class Reference
[Localization]

Defines a specific language, country, and variant. More...

#include <rw/i18n/RWULocale.h>

List of all members.

Public Member Functions

 RWULocale ()
 RWULocale (const RWCString &fullName)
 RWULocale (const char *fullName)
 RWULocale (const char *language, const char *country, const char *variant=0)
RWULocaleoperator= (const RWULocale &other)
bool operator== (const RWULocale &other) const
bool operator!= (const RWULocale &other) const
RWCString getLanguage () const
RWCString getCountry () const
RWCString getVariant () const
RWCString getName () const
const RWCString getIso3Language () const
const RWCString getIso3Country () const
uint32_t getLCID () const
RWUString getDisplayName (const RWULocale &inLocale=RWULocale::getDefault()) const
RWUString getDisplayLanguage (const RWULocale &inLocale=RWULocale::getDefault()) const
RWUString getDisplayCountry (const RWULocale &inLocale=RWULocale::getDefault()) const
RWUString getDisplayVariant (const RWULocale &inLocale=RWULocale::getDefault()) const
uint32_t hash () const

Static Public Member Functions

static RWULocale getDefault ()
static void setDefault (const RWULocale &newDefault)

Detailed Description

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:

http://www.iso.ch

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.

See also:
RWUAvailableLocaleList, RWUAvailableLocaleListIterator, RWUResourceBundle

Constructor & Destructor Documentation

RWULocale::RWULocale (  )  [inline]

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::RWULocale ( const RWCString fullName  )  [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.

Note:
Passing an empty string does not create an empty RWULocale, but instead creates a copy of the current default RWULocale.
See also:
getDefault(), setDefault()
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.

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(), setDefault()
RWULocale::RWULocale ( const char *  language,
const char *  country,
const char *  variant = 0 
) [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.


Member Function Documentation

RWCString RWULocale::getCountry (  )  const [inline]

Returns self's ISO-3166 country code (two characters).

RWULocale RWULocale::getDefault ( void   )  [inline, static]

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.

const RWCString RWULocale::getIso3Country (  )  const [inline]

Returns self's country code. See ISO-3166.

const RWCString RWULocale::getIso3Language (  )  const [inline]

Returns self's language code. See ISO draft standard ISO-639-2 (more than two characters).

RWCString RWULocale::getLanguage (  )  const [inline]

Returns self's ISO-639 language code (two characters).

uint32_t RWULocale::getLCID (  )  const [inline]

Returns the Windows LCID value of self. Returns 0 in case of missing resource, wrong format, or non-Windows operating system.

RWCString RWULocale::getName (  )  const [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.

RWCString RWULocale::getVariant (  )  const [inline]

Returns self's variant (not per any standard).

uint32_t RWULocale::hash (  )  const [inline]

Returns a hash code for self.

bool RWULocale::operator!= ( const RWULocale other  )  const [inline]

Returns true if RWULocale other does not have the same name as self; otherwise, false.

RWULocale & RWULocale::operator= ( const RWULocale other  )  [inline]

Assignment operator. Replaces self with other.

bool RWULocale::operator== ( const RWULocale other  )  const [inline]

Returns true if RWULocale other has the same name as self; otherwise, false.

static void RWULocale::setDefault ( const RWULocale newDefault  )  [static]

Sets the value of the default RWULocale to newDefault.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.