libzypp: zyppng::Locale Class Reference

libzypp 17.38.10

zyppng::Locale Class Reference

'Language[_Country]' codes. More...

`#include <zypp/Locale.h>`

Inheritance diagram for zyppng::Locale:

## Public Member Functions
| Locale ()
| Default Ctor: noCode.
| Locale (IdString str_r)
| Ctor from string.
| Locale (const std::string &str_r)
| Ctor from string.
| Locale (const char *str_r)
| Ctor from string.
| Locale (const LanguageCode &language_r, const CountryCode &country_r=CountryCode())
| Ctor taking LanguageCode and optional CountryCode.
| ~Locale ()
| Dtor.
Public Member Functions inherited from zypp::IdStringType< Locale >
IdString | idStr () const
bool | empty () const
unsigned | size () const
const char * | c_str () const
std::string | asString () const
IdType | id () const
| operator bool () const
| Evaluate in a boolean context ( !
| operator IdString () const
| Explicit conversion to IdString.
| operator std::string () const
| Explicit conversion to std::string.
int | compare (const Locale &rhs) const
int | compare (const IdStringType &rhs) const
int | compare (const IdString &rhs) const
int | compare (const std::string &rhs) const
int | compare (const char *rhs) const

## Locale constants.
static const Locale | noCode
| Empty code.
static const Locale | enCode
| Last resort "en".
class | IdStringType< Locale >
IdString | _str
LanguageCode | language () const
| The language part.
CountryCode | country () const
| The county part.
std::string | code () const
| Return the locale code asString.
std::string | name () const
| Return the translated locale name.
Locale | fallback () const
| Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
static Locale | bestMatch (const LocaleSet &avLocales_r, Locale requested_r=Locale())
| Return the best match for Locale requested_r within the available avLocales_r.

## Additional Inherited Members
Public Types inherited from zypp::IdStringType< Locale >
using | IdType
Static Public Member Functions inherited from zypp::IdStringType< Locale >
static int | compare (const Locale &lhs, const Locale &rhs)
static int | compare (const Locale &lhs, const IdString &rhs)
static int | compare (const Locale &lhs, const std::string &rhs)
static int | compare (const Locale &lhs, const char *rhs)
static int | compare (const IdString &lhs, const Locale &rhs)
static int | compare (const IdString &lhs, const IdString &rhs)
static int | compare (const IdString &lhs, const std::string &rhs)
static int | compare (const IdString &lhs, const char *rhs)
static int | compare (const std::string &lhs, const Locale &rhs)
static int | compare (const std::string &lhs, const IdString &rhs)
static int | compare (const std::string &lhs, const std::string &rhs)
static int | compare (const std::string &lhs, const char *rhs)
static int | compare (const char *lhs, const Locale &rhs)
static int | compare (const char *lhs, const IdString &rhs)
static int | compare (const char *lhs, const std::string &rhs)
static int | compare (const char *lhs, const char *rhs)
Protected Member Functions inherited from zypp::IdStringType< Locale >
| IdStringType ()=default
| IdStringType (const IdStringType &)=default
| IdStringType (IdStringType &&) noexcept=default
IdStringType & | operator= (const IdStringType &)=default
IdStringType & | operator= (IdStringType &&) noexcept=default
| ~IdStringType ()=default

## Detailed Description

'Language[_Country]' codes.

In fact the class will not prevent to use a non iso code. Just a warning will appear in the log. Construction from string consider everything up to the first `'`.' or `'@'`.

Locale l( "de_DE.UTF-8" );
l.code() == "de_DE";
l.language() == "de";
l.country() == "DE";
l.fallback() == "de";
l.fallback().fallback() == Locale::enCode == "en";
l.fallback().fallback().fallback() == Locale::noCode == "";
zyppng::Locale::enCode
static const Locale enCode
Last resort "en".
Definition Locale.h:78
zyppng::Locale::noCode
static const Locale noCode
Empty code.
Definition Locale.h:75
zyppng::Locale::Locale
Locale()
Default Ctor: noCode.
Definition Locale.cc:180

Definition at line 50 of file Locale.h.

## Constructor & Destructor Documentation

## ◆ Locale() [1/5]

zypp::Locale::Locale | ( |  | ) |

Default Ctor: noCode.

Definition at line 180 of file Locale.cc.

## ◆ Locale() [2/5]

zypp::Locale::Locale | ( | IdString | str_r | ) |
| explicit

Ctor from string.

Definition at line 183 of file Locale.cc.

## ◆ Locale() [3/5]

zypp::Locale::Locale | ( | const std::string & | str_r | ) |
| explicit

Ctor from string.

Definition at line 187 of file Locale.cc.

## ◆ Locale() [4/5]

zypp::Locale::Locale | ( | const char * | str_r | ) |
| explicit

Ctor from string.

Definition at line 191 of file Locale.cc.

## ◆ Locale() [5/5]

zypp::Locale::Locale | ( | const LanguageCode & | language_r,
|  | const CountryCode & | country_r = CountryCode() )

Ctor taking LanguageCode and optional CountryCode.

Definition at line 195 of file Locale.cc.

## ◆ ~Locale()

zypp::Locale::~Locale | ( |  | ) |

Dtor.

Definition at line 199 of file Locale.cc.

## Member Function Documentation

## ◆ language()

LanguageCode zypp::Locale::language | ( |  | ) | const

The language part.

Definition at line 202 of file Locale.cc.

## ◆ country()

CountryCode zypp::Locale::country | ( |  | ) | const

The county part.

Definition at line 205 of file Locale.cc.

## ◆ code()

std::string zypp::Locale::code | ( |  | ) | const
| inline

Return the locale code asString.

Definition at line 89 of file Locale.h.

## ◆ name()

std::string zypp::Locale::name | ( |  | ) | const

Return the translated locale name.

Definition at line 208 of file Locale.cc.

## ◆ fallback()

Locale zypp::Locale::fallback | ( |  | ) | const

Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.

The usual fallback sequence is "language_COUNTRY" -> "language" -> Locale::enCode ("en") ->Locale::noCode (""). Some exceptions like "pt_BR"->"en"->"" do exist.

Definition at line 211 of file Locale.cc.

## ◆ bestMatch()

Locale zypp::Locale::bestMatch | ( | const LocaleSet & | avLocales_r,
|  | Locale | requested_r = Locale() )
| static

Return the best match for Locale requested_r within the available avLocales_r.

If requested_r is not specified ZConfig::textLocale is assumed.

If neither `requested_r` nor any of its fallback locales are available in avLocales_r, Locale::noCode is returned.

Definition at line 215 of file Locale.cc.

## Friends And Related Symbol Documentation

## ◆ IdStringType< Locale >

friend class IdStringType< Locale >
| friend

Definition at line 110 of file Locale.h.

## Member Data Documentation

## ◆ noCode

const Locale zypp::Locale::noCode
| static

Empty code.

Definition at line 75 of file Locale.h.

## ◆ enCode

const Locale zypp::Locale::enCode
| static

Last resort "en".

Definition at line 78 of file Locale.h.

## ◆ _str

IdString zypp::Locale::_str
| private

Definition at line 115 of file Locale.h.

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

- zypp/Locale.h
- zypp/Locale.cc