20 #ifndef HEADER_TINYGETTEXT_LANGUAGE_HPP 21 #define HEADER_TINYGETTEXT_LANGUAGE_HPP 24 #include <unordered_map> 42 const std::string& country = std::string(),
43 const std::string& modifier = std::string());
61 explicit operator bool()
const {
return language_spec !=
nullptr; }
78 std::string
str()
const;
std::string get_language() const
Returns the language code (i.e.
Definition: language.cpp:505
std::string get_name() const
Returns the human readable name of the Language.
Definition: language.cpp:532
bool operator==(const Language &rhs) const
Definition: language.cpp:567
Lightweight wrapper around LanguageSpec.
Definition: language.hpp:31
size_t operator()(const Language &v) const
Definition: language.hpp:93
const LanguageSpec * language_spec
Definition: language.hpp:34
std::string get_country() const
Returns the country code (i.e.
Definition: language.cpp:514
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");.
Definition: language.cpp:374
Definition: language.hpp:91
Language()
Create an undefined Language object.
Definition: language.cpp:463
std::string str() const
Returns the Language as string in the form of an environment variable: {language}_{country}modifier}...
Definition: language.cpp:541
Definition: language.cpp:31
bool operator!=(const Language &rhs) const
Definition: language.cpp:573
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.
Definition: language.cpp:469
static Language from_env(const std::string &env)
Create a language from an environment variable style string (e.g de_DE.UTF-8)
Definition: language.cpp:424
friend bool operator<(const Language &lhs, const Language &rhs)
Definition: language.hpp:87
std::string get_modifier() const
Returns the modifier of the language (i.e.
Definition: language.cpp:523
static Language from_name(const std::string &str)
Create a language from language and country code: Example: Languge("deutsch"); Example: Languge("de_D...
Definition: language.cpp:418