]> git.lyx.org Git - lyx.git/blob - src/support/Messages.h
Fix text direction issue for InsetInfo in RTL context
[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         /// dummy instantiation: no translation is done
25         Messages() {}
26         /// messages in the language \p l.
27         Messages(std::string const & l);
28         /// Return the tranlation of message \c msg, or the original
29         /// string if no context was found. Context is always removed.
30         docstring const get(std::string const & msg) const;
31         ///
32         docstring const getIfFound(std::string const & msg) const;
33         /// What is the language associated with this translation?
34         std::string language() const;
35         /// Is an (at least partial) translation of language with code \p c available?
36         static bool available(std::string const & c);
37         ///
38         static void guiLanguage(std::string const & l) { gui_lang_ = l; }
39         ///
40         static std::string const & guiLanguage() { return gui_lang_; }
41
42 private:
43         /// Read the strings from the .mo file. Returns true on success.
44         bool readMoFile();
45         ///
46         std::string lang_;
47         ///
48         typedef std::map<std::string, docstring> TranslationMap;
49         TranslationMap trans_map_;
50         /// The language used by the Gui
51         static std::string gui_lang_;
52 };
53
54 /// Access to the unique Messages object for the passed \p language.
55 /// Implementation is in LyX.cpp.
56 extern Messages const & getMessages(std::string const & language);
57 /// Access to the unique Messages object used for GUI element.
58 /// Implementation is in LyX.cpp.
59 extern Messages const & getGuiMessages();
60
61 /// Remove the context suffix from \p trans
62 extern void cleanTranslation(docstring & trans);
63
64 } // namespace lyx
65
66 #endif