Pyrogenesis
trunk
|
Manager class for dictionaries, you give it a bunch of directories with .po files and it will then automatically load the right file on demand depending on which language was set. More...
#include <dictionary_manager.hpp>
Public Member Functions | |
DictionaryManager (const std::string &charset_="UTF-8") | |
~DictionaryManager () | |
Dictionary & | get_dictionary () |
Return the currently active dictionary, if none is set, an empty dictionary is returned. More... | |
Dictionary & | get_dictionary (const Language &language) |
Get dictionary for language. More... | |
void | set_language (const Language &language) |
Set a language based on a four? letter country code. More... | |
Language | get_language () const |
returns the (normalized) country code of the currently used language More... | |
void | set_use_fuzzy (bool t) |
bool | get_use_fuzzy () const |
void | set_charset (const std::string &charset) |
Set a charset that will be set on the returned dictionaries. More... | |
void | add_directory (const std::string &pathname) |
Add a directory to the search path for dictionaries, earlier added directories have higher priority then later added ones. More... | |
std::set< Language > | get_languages () |
Return a set of the available languages in their country code. More... | |
void | set_filesystem (std::unique_ptr< FileSystem > filesystem) |
std::string | convertFilename2Language (const std::string &s_in) const |
This function converts a .po filename (e.g. More... | |
Private Types | |
typedef std::unordered_map< Language, Dictionary *, Language_hash > | Dictionaries |
typedef std::vector< std::string > | SearchPath |
Private Member Functions | |
void | clear_cache () |
DictionaryManager (const DictionaryManager &) | |
DictionaryManager & | operator= (const DictionaryManager &) |
Private Attributes | |
Dictionaries | dictionaries |
SearchPath | search_path |
std::string | charset |
bool | use_fuzzy |
Language | current_language |
Dictionary * | current_dict |
Dictionary | empty_dict |
std::unique_ptr< FileSystem > | filesystem |
Manager class for dictionaries, you give it a bunch of directories with .po files and it will then automatically load the right file on demand depending on which language was set.
|
private |
|
private |
tinygettext::DictionaryManager::DictionaryManager | ( | const std::string & | charset_ = "UTF-8" | ) |
tinygettext::DictionaryManager::~DictionaryManager | ( | ) |
|
private |
void tinygettext::DictionaryManager::add_directory | ( | const std::string & | pathname | ) |
Add a directory to the search path for dictionaries, earlier added directories have higher priority then later added ones.
|
private |
std::string tinygettext::DictionaryManager::convertFilename2Language | ( | const std::string & | s_in | ) | const |
This function converts a .po filename (e.g.
zh_TW.po) into a language specification (zh_TW). On case insensitive file systems (think windows) the filename and therefore the country specification is lower case (zh_tw). It Converts the lower case characters of the country back to upper case, otherwise tinygettext does not identify the country correctly.
Dictionary & tinygettext::DictionaryManager::get_dictionary | ( | ) |
Return the currently active dictionary, if none is set, an empty dictionary is returned.
Dictionary & tinygettext::DictionaryManager::get_dictionary | ( | const Language & | language | ) |
Get dictionary for language.
Language tinygettext::DictionaryManager::get_language | ( | ) | const |
returns the (normalized) country code of the currently used language
std::set< Language > tinygettext::DictionaryManager::get_languages | ( | ) |
Return a set of the available languages in their country code.
bool tinygettext::DictionaryManager::get_use_fuzzy | ( | ) | const |
|
private |
void tinygettext::DictionaryManager::set_charset | ( | const std::string & | charset | ) |
Set a charset that will be set on the returned dictionaries.
void tinygettext::DictionaryManager::set_filesystem | ( | std::unique_ptr< FileSystem > | filesystem | ) |
void tinygettext::DictionaryManager::set_language | ( | const Language & | language | ) |
Set a language based on a four? letter country code.
void tinygettext::DictionaryManager::set_use_fuzzy | ( | bool | t | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |