1 // tinygettext - A gettext replacement that works directly on .po files
2 // Copyright (C) 2006 Ingo Ruhnke <grumbel@gmx.de>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef HEADER_TINYGETTEXT_DICTIONARY_MANAGER_HPP
19 #define HEADER_TINYGETTEXT_DICTIONARY_MANAGER_HPP
27 #include "dictionary.hpp"
28 #include "language.hpp"
30 namespace tinygettext {
34 /** Manager class for dictionaries, you give it a bunch of directories
35 with .po files and it will then automatically load the right file
36 on demand depending on which language was set. */
37 class DictionaryManager
40 typedef std::map<Language, Dictionary*> Dictionaries;
41 Dictionaries dictionaries;
43 typedef std::vector<std::string> SearchPath;
44 SearchPath search_path;
49 Language current_language;
50 Dictionary* current_dict;
52 Dictionary empty_dict;
54 std::auto_ptr<FileSystem> filesystem;
59 DictionaryManager(const std::string& charset_ = "UTF-8");
62 /** Return the currently active dictionary, if none is set, an empty
63 dictionary is returned. */
64 Dictionary& get_dictionary();
66 /** Get dictionary for language */
67 Dictionary& get_dictionary(const Language& language);
69 /** Set a language based on a four? letter country code */
70 void set_language(const Language& language);
72 /** returns the (normalized) country code of the currently used language */
73 Language get_language() const;
75 void set_use_fuzzy(bool t);
76 bool get_use_fuzzy() const;
78 /** Set a charset that will be set on the returned dictionaries */
79 void set_charset(const std::string& charset);
81 /** Add a directory to the search path for dictionaries, earlier
82 added directories have higher priority then later added ones */
83 void add_directory(const std::string& pathname);
85 /** Return a set of the available languages in their country code */
86 std::set<Language> get_languages();
88 void set_filesystem(std::auto_ptr<FileSystem> filesystem);
91 DictionaryManager (const DictionaryManager&);
92 DictionaryManager& operator= (const DictionaryManager&);
95 } // namespace tinygettext