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) 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

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

Create an undefined Language object.

Member Function Documentation

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)

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");.

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");.

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

Returns the country code (i.e.

DE, AT, US)

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

Returns the language code (i.e.

de, en, fr)

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

Returns the modifier of the language (i.e.

latn or Latn for Serbian with non-cyrilic characters)

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

Returns the human readable name of the Language.

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.

tinygettext::Language::operator bool ( ) const
inlineexplicit
bool tinygettext::Language::operator!= ( const Language rhs) const
bool tinygettext::Language::operator== ( const Language rhs) const
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

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

Member Data Documentation

const LanguageSpec* tinygettext::Language::language_spec
private

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