]> git.lyx.org Git - lyx.git/blob - src/support/Messages.h
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / support / Messages.h
1 // -*- C++ -*-
2 /* \file Messages.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #ifndef MESSAGES_H
12 #define MESSAGES_H
13
14 #include "support/docstring.h"
15
16 #include <map>
17 #include <string>
18
19 namespace lyx {
20
21 ///
22 class Messages {
23 public:
24         /// messages in the language \p l.
25         /// If \p l is empty, the language will be defined by the environment.
26         Messages(std::string const & l = std::string());
27         ///
28         docstring const get(std::string const & msg) const;
29         /// Is an (at least partial) translation of this language available?
30         bool available() const;
31         ///
32         static void init();
33         ///
34         static std::string const & defaultLanguage() { return main_lang_; }
35
36 private:
37         ///
38         static void setDefaultLanguage();
39         ///
40         static std::string main_lang_;
41         ///
42         std::string lang_;
43         /// Did we warn about unavailable locale already?
44         mutable bool warned_;
45         ///
46         typedef std::map<std::string, docstring> TranslationCache;
47         /// Internal cache for gettext translated strings.
48         /// This is needed for performance reason within \c updateBuffer()
49         /// under Windows.
50         mutable TranslationCache cache_;
51 };
52
53 /// Access to the unique Messages object for the passed \p language.
54 /// Implementation is in LyX.cpp.
55 extern Messages const & getMessages(std::string const & language);
56 /// Access to the unique Messages object used for GUI element.
57 /// Implementation is in LyX.cpp.
58 extern Messages const & getGuiMessages();
59
60 /// Remove the context suffix from \p trans
61 extern void cleanTranslation(docstring & trans);
62
63 } // namespace lyx
64
65 #endif