Pyrogenesis trunk
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
tinygettext::Language Class Reference

Lightweight wrapper around LanguageSpec. More...

#include <language.hpp>

Collaboration diagram for tinygettext::Language:
Collaboration graph
[legend]

Public Member Functions

 Language ()
 Create an undefined Language object. More...
 
 operator bool () const
 
std::string get_language () const
 Returns the language code (i.e. More...
 
std::string get_country () const
 Returns the country code (i.e. More...
 
std::string get_modifier () const
 Returns the modifier of the language (i.e. More...
 
std::string get_name () const
 Returns the human readable name of the Language. More...
 

Static Public Member Functions

static Language from_spec (const std::string &language, const std::string &country=std::string(), const std::string &modifier=std::string())
 Create a language from language and country code: Example: Languge("de", "DE");. More...
 
static Language from_name (const std::string &str)
 Create a language from language and country code: Example: Languge("deutsch"); Example: Languge("de_DE");. More...
 
static Language from_env (const std::string &env)
 Create a language from an environment variable style string (e.g de_DE.UTF-8@modifier) More...
 
static int match (const Language &lhs, const Language &rhs)
 Compares two Languages, returns 0 on missmatch and a score between 1 and 9 on match, the higher the score the better the match. More...
 

Private Member Functions

 Language (const LanguageSpec *language_spec)
 

Private Attributes

const LanguageSpeclanguage_spec
 
struct Language_hash
 
bool operator< (const Language &lhs, const Language &rhs)
 
std::string str () const
 Returns the Language as string in the form of an environment variable: {language}_{country}modifier}. More...
 
bool operator== (const Language &rhs) const
 
bool operator!= (const Language &rhs) const
 

Detailed Description

Lightweight wrapper around LanguageSpec.

Constructor & Destructor Documentation

◆ Language() [1/2]

tinygettext::Language::Language ( const LanguageSpec language_spec)
private

◆ Language() [2/2]

tinygettext::Language::Language ( )

Create an undefined Language object.

Member Function Documentation

◆ from_env()

Language tinygettext::Language::from_env ( const std::string &  env)
static

Create a language from an environment variable style string (e.g de_DE.UTF-8@modifier)

◆ from_name()

Language tinygettext::Language::from_name ( const std::string &  str)
static

Create a language from language and country code: Example: Languge("deutsch"); Example: Languge("de_DE");.

◆ from_spec()

Language tinygettext::Language::from_spec ( const std::string &  language,
const std::string &  country = std::string(),
const std::string &  modifier = std::string() 
)
static

Create a language from language and country code: Example: Languge("de", "DE");.

◆ get_country()

std::string tinygettext::Language::get_country ( ) const

Returns the country code (i.e.

DE, AT, US)

◆ get_language()

std::string tinygettext::Language::get_language ( ) const

Returns the language code (i.e.

de, en, fr)

◆ get_modifier()

std::string tinygettext::Language::get_modifier ( ) const

Returns the modifier of the language (i.e.

latn or Latn for Serbian with non-cyrilic characters)

◆ get_name()

std::string tinygettext::Language::get_name ( ) const

Returns the human readable name of the Language.

◆ match()

int tinygettext::Language::match ( const Language lhs,
const Language rhs 
)
static

Compares two Languages, returns 0 on missmatch and a score between 1 and 9 on match, the higher the score the better the match.

◆ operator bool()

tinygettext::Language::operator bool ( ) const
inlineexplicit

◆ operator!=()

bool tinygettext::Language::operator!= ( const Language rhs) const

◆ operator==()

bool tinygettext::Language::operator== ( const Language rhs) const

◆ str()

std::string tinygettext::Language::str ( ) const

Returns the Language as string in the form of an environment variable: {language}_{country}modifier}.

Friends And Related Function Documentation

◆ Language_hash

friend struct Language_hash
friend

◆ operator<

bool operator< ( const Language lhs,
const Language rhs 
)
friend

Member Data Documentation

◆ language_spec

const LanguageSpec* tinygettext::Language::language_spec
private

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