SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

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

#include <rw/i18n/RWULocale.h>

Public Member Functions

 RWULocale ()
 
 RWULocale (const char *fullName)
 
 RWULocale (const char *language, const char *country, const char *variant=0)
 
 RWULocale (const RWCString &fullName)
 
 RWULocale (const RWULocale &other)
 
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
 
RWULocaleoperator= (const RWULocale &other)
 
bool operator== (const RWULocale &other) const
 

Static Public Member Functions

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

Friends

class RWUResourceBundle
 
class RWUString
 

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

See also
RWUAvailableLocaleList, RWUAvailableLocaleListIterator, RWUResourceBundle

Constructor & Destructor Documentation

◆ RWULocale() [1/5]

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() [2/5]

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() [3/5]

RWULocale::RWULocale ( const RWULocale & other)
inline

Constructs an RWULocale that is a copy of other.

◆ RWULocale() [4/5]

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() [5/5]

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

◆ getCountry()

RWCString RWULocale::getCountry ( ) const
inline

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

◆ getDefault()

RWULocale RWULocale::getDefault ( )
inlinestatic

Returns the default RWULocale. The initial default is set at startup time to some system-specific value.

◆ getDisplayCountry()

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.

◆ getDisplayLanguage()

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.

◆ getDisplayName()

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.

◆ getDisplayVariant()

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.

◆ getIso3Country()

const RWCString RWULocale::getIso3Country ( ) const
inline

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

◆ getIso3Language()

const RWCString RWULocale::getIso3Language ( ) const
inline

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

◆ getLanguage()

RWCString RWULocale::getLanguage ( ) const
inline

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

◆ getLCID()

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.

◆ getName()

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.

◆ getVariant()

RWCString RWULocale::getVariant ( ) const
inline

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

◆ hash()

uint32_t RWULocale::hash ( ) const
inline

Returns a hash code for self.

◆ operator!=()

bool RWULocale::operator!= ( const RWULocale & other) const
inline

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

◆ operator=()

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

Assignment operator. Replaces self with other.

◆ operator==()

bool RWULocale::operator== ( const RWULocale & other) const
inline

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

◆ setDefault()

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

Sets the value of the default RWULocale to newDefault.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.