]> git.lyx.org Git - lyx.git/blob - src/support/Messages.h
12a5b40e800d1146f82bda3a3ce406d42e8f6182
[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         ///
30         static void init();
31         ///
32         static std::string const & defaultLanguage() { return main_lang_; }
33
34 private:
35         ///
36         static void setDefaultLanguage();
37         ///
38         static std::string main_lang_;
39         ///
40         std::string lang_;
41         /// Did we warn about unavailable locale already?
42         mutable bool warned_;
43         ///
44         typedef std::map<std::string, docstring> TranslationCache;
45         /// Internal cache for gettext translated strings.
46         /// This is needed for performance reason within \c updateLabels()
47         /// under Windows.
48         mutable TranslationCache cache_;
49 };
50
51 /// Access to the unique Messages object for the passed \p language.
52 /// Implementation is in LyX.cpp.
53 extern Messages & getMessages(std::string const & language);
54 /// Access to the unique Messages object used for GUI element.
55 /// Implementation is in LyX.cpp.
56 extern Messages & getGuiMessages();
57
58 } // namespace lyx
59
60 #endif