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

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>

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

Public Member Functions

 DictionaryManager (const std::string &charset_="UTF-8")
 
 ~DictionaryManager ()
 
Dictionaryget_dictionary ()
 Return the currently active dictionary, if none is set, an empty dictionary is returned. More...
 
Dictionaryget_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< Languageget_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_hashDictionaries
 
typedef std::vector< std::string > SearchPath
 

Private Member Functions

void clear_cache ()
 
 DictionaryManager (const DictionaryManager &)
 
DictionaryManageroperator= (const DictionaryManager &)
 

Private Attributes

Dictionaries dictionaries
 
SearchPath search_path
 
std::string charset
 
bool use_fuzzy
 
Language current_language
 
Dictionarycurrent_dict
 
Dictionary empty_dict
 
std::unique_ptr< FileSystemfilesystem
 

Detailed Description

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.

Member Typedef Documentation

typedef std::vector<std::string> tinygettext::DictionaryManager::SearchPath
private

Constructor & Destructor Documentation

tinygettext::DictionaryManager::DictionaryManager ( const std::string &  charset_ = "UTF-8")
tinygettext::DictionaryManager::~DictionaryManager ( )
tinygettext::DictionaryManager::DictionaryManager ( const DictionaryManager )
private

Member Function Documentation

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.

void tinygettext::DictionaryManager::clear_cache ( )
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
DictionaryManager& tinygettext::DictionaryManager::operator= ( const DictionaryManager )
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)

Member Data Documentation

std::string tinygettext::DictionaryManager::charset
private
Dictionary* tinygettext::DictionaryManager::current_dict
private
Language tinygettext::DictionaryManager::current_language
private
Dictionaries tinygettext::DictionaryManager::dictionaries
private
Dictionary tinygettext::DictionaryManager::empty_dict
private
std::unique_ptr<FileSystem> tinygettext::DictionaryManager::filesystem
private
SearchPath tinygettext::DictionaryManager::search_path
private
bool tinygettext::DictionaryManager::use_fuzzy
private

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