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, bool precedence=false)
 Add a directory to the search path for dictionaries, earlier added directories have higher priority then later added ones. More...
 
void remove_directory (const std::string &pathname)
 Remove a directory from the search path. 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::deque< 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

◆ Dictionaries

◆ SearchPath

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

Constructor & Destructor Documentation

◆ DictionaryManager() [1/2]

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

◆ ~DictionaryManager()

tinygettext::DictionaryManager::~DictionaryManager ( )

◆ DictionaryManager() [2/2]

tinygettext::DictionaryManager::DictionaryManager ( const DictionaryManager )
private

Member Function Documentation

◆ add_directory()

void tinygettext::DictionaryManager::add_directory ( const std::string &  pathname,
bool  precedence = false 
)

Add a directory to the search path for dictionaries, earlier added directories have higher priority then later added ones.

Set precedence to true to invert this for a single addition.

◆ clear_cache()

void tinygettext::DictionaryManager::clear_cache ( )
private

◆ convertFilename2Language()

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.

◆ get_dictionary() [1/2]

Dictionary & tinygettext::DictionaryManager::get_dictionary ( )

Return the currently active dictionary, if none is set, an empty dictionary is returned.

◆ get_dictionary() [2/2]

Dictionary & tinygettext::DictionaryManager::get_dictionary ( const Language language)

Get dictionary for language.

◆ get_language()

Language tinygettext::DictionaryManager::get_language ( ) const

returns the (normalized) country code of the currently used language

◆ get_languages()

std::set< Language > tinygettext::DictionaryManager::get_languages ( )

Return a set of the available languages in their country code.

◆ get_use_fuzzy()

bool tinygettext::DictionaryManager::get_use_fuzzy ( ) const

◆ operator=()

DictionaryManager& tinygettext::DictionaryManager::operator= ( const DictionaryManager )
private

◆ remove_directory()

void tinygettext::DictionaryManager::remove_directory ( const std::string &  pathname)

Remove a directory from the search path.

◆ set_charset()

void tinygettext::DictionaryManager::set_charset ( const std::string &  charset)

Set a charset that will be set on the returned dictionaries.

◆ set_filesystem()

void tinygettext::DictionaryManager::set_filesystem ( std::unique_ptr< FileSystem filesystem)

◆ set_language()

void tinygettext::DictionaryManager::set_language ( const Language language)

Set a language based on a four? letter country code.

◆ set_use_fuzzy()

void tinygettext::DictionaryManager::set_use_fuzzy ( bool  t)

Member Data Documentation

◆ charset

std::string tinygettext::DictionaryManager::charset
private

◆ current_dict

Dictionary* tinygettext::DictionaryManager::current_dict
private

◆ current_language

Language tinygettext::DictionaryManager::current_language
private

◆ dictionaries

Dictionaries tinygettext::DictionaryManager::dictionaries
private

◆ empty_dict

Dictionary tinygettext::DictionaryManager::empty_dict
private

◆ filesystem

std::unique_ptr<FileSystem> tinygettext::DictionaryManager::filesystem
private

◆ search_path

SearchPath tinygettext::DictionaryManager::search_path
private

◆ use_fuzzy

bool tinygettext::DictionaryManager::use_fuzzy
private

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