You.i Engine
CYILocale Class Reference

Detailed Description

A class representing a locale.

Instances of this class represent locales. Locales are typically instantiated with a 2 character ISO-639-1 language code and a 2 character ISO-3166-1 country code though it is possible to default construct a locale. Additionally, this class manages the global locale.

#include <utility/YiLocale.h>

Public Types

enum  LocaleStringFormat {
  LocaleStringFormat::Concatenated,
  LocaleStringFormat::Raw
}
 

Public Member Functions

 CYILocale ()
 
 CYILocale (const CYIString &rLanguageCode, const CYIString &rCountryCode)
 
 CYILocale (const CYIString &rLanguageCode, const CYIString &rCountryCode, const CYIString &rRawLocaleString)
 
virtual ~CYILocale ()
 
const CYIStringGetLanguageCode () const
 
const CYIStringGetCountryCode () const
 
CYIString ToString (LocaleStringFormat format=LocaleStringFormat::Concatenated) const
 

Static Public Member Functions

static const CYILocaleGetLocale ()
 
static void SetLocale (const CYILocale &rLocale)
 
static const CYIStringCountryCodeAlpha3ToAlpha2 (const CYIString &country)
 

Protected Attributes

CYIString m_LanguageCode
 
CYIString m_CountryCode
 
CYIString m_RawLocaleString
 

Member Enumeration Documentation

◆ LocaleStringFormat

The format of locale string.

Enumerator
Concatenated 

The locale string as language and country codes concatenated together. This format is consistent across all platforms.

Raw 

The raw locale string as returned by the system.

Constructor & Destructor Documentation

◆ CYILocale() [1/3]

CYILocale::CYILocale ( )

Constructs an empty locale.

◆ CYILocale() [2/3]

CYILocale::CYILocale ( const CYIString rLanguageCode,
const CYIString rCountryCode 
)

Constructs a locale with the given language and country codes. The language code should be a valid 2 character ISO-639-1 code and the country code should be a valid 2 character ISO-3166-1 code. This constructor doesn't assign a raw platform locale string. No validation is performed on the provided codes.

◆ CYILocale() [3/3]

CYILocale::CYILocale ( const CYIString rLanguageCode,
const CYIString rCountryCode,
const CYIString rRawLocaleString 
)

Constructs a locale with the given language, country code, and the raw locale string. The language code should be a valid 2 character ISO-639-1 code and the country code should be a valid 2 character ISO-3166-1 code. The raw locale string is provided from some platforms' native APIs. No validation is performed on the provided codes.

◆ ~CYILocale()

virtual CYILocale::~CYILocale ( )
virtual

Destroys the locale.

Member Function Documentation

◆ CountryCodeAlpha3ToAlpha2()

static const CYIString& CYILocale::CountryCodeAlpha3ToAlpha2 ( const CYIString country)
static

Converts an ISO 3166-1 alpha 3 country code, country, to an ISO 3166-1 alpha 2 country code.

◆ GetCountryCode()

const CYIString& CYILocale::GetCountryCode ( ) const

Returns the country code if the locale has one and an empty string otherwise. If the locale has a country code it is usually a 2 character ISO-3166-1 code but this is not guaranteed.

◆ GetLanguageCode()

const CYIString& CYILocale::GetLanguageCode ( ) const

Returns the language code if the locale has one and an empty string otherwise. If the locale has a language code it is usually a 2 character ISO-639-1 code but this is not guaranteed.

◆ GetLocale()

static const CYILocale& CYILocale::GetLocale ( )
static

Returns the global locale.

◆ SetLocale()

static void CYILocale::SetLocale ( const CYILocale rLocale)
static

Sets the global locale.

◆ ToString()

CYIString CYILocale::ToString ( LocaleStringFormat  format = LocaleStringFormat::Concatenated) const

Returns a string representation of the locale or an empty string. The string representation is in the form of "en_US" where en is the language code (English) and US is the country code (United States) or the original raw string returned by the system. format specifies the locale string format returned.

Member Data Documentation

◆ m_CountryCode

CYIString CYILocale::m_CountryCode
protected

◆ m_LanguageCode

CYIString CYILocale::m_LanguageCode
protected

◆ m_RawLocaleString

CYIString CYILocale::m_RawLocaleString
protected

The documentation for this class was generated from the following file: