2003-04-23 18:47:21 +00:00
|
|
|
// -*- C++ -*-
|
2007-04-26 04:41:58 +00:00
|
|
|
/* \file Messages.h
|
2003-04-23 20:44:53 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
2003-04-23 18:47:21 +00:00
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-04-23 18:47:21 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-04-23 18:47:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MESSAGES_H
|
|
|
|
#define MESSAGES_H
|
|
|
|
|
2006-09-09 11:16:28 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2007-01-14 09:55:08 +00:00
|
|
|
#include <map>
|
2003-10-07 06:45:25 +00:00
|
|
|
#include <string>
|
2003-04-23 18:47:21 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
///
|
|
|
|
class Messages {
|
|
|
|
public:
|
2013-05-31 09:57:50 +00:00
|
|
|
/// dummy instantiation: no translation is done
|
|
|
|
Messages() {}
|
2007-01-14 09:55:08 +00:00
|
|
|
/// messages in the language \p l.
|
2013-05-31 09:57:50 +00:00
|
|
|
Messages(std::string const & l);
|
2003-04-23 18:47:21 +00:00
|
|
|
///
|
2007-01-14 09:55:08 +00:00
|
|
|
docstring const get(std::string const & msg) const;
|
2012-07-15 20:22:10 +00:00
|
|
|
/// What is the language associated with this translation?
|
|
|
|
std::string language() const;
|
2012-08-23 13:08:21 +00:00
|
|
|
/// Is an (at least partial) translation of language with code \p c available?
|
|
|
|
static bool available(std::string const & c);
|
2007-08-07 22:24:47 +00:00
|
|
|
///
|
2013-05-08 16:50:38 +00:00
|
|
|
static void guiLanguage(std::string const & l) { gui_lang_ = l; }
|
|
|
|
///
|
|
|
|
static std::string const & guiLanguage() { return gui_lang_; }
|
2008-07-28 11:26:46 +00:00
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
private:
|
2013-05-08 16:50:38 +00:00
|
|
|
/// Read the strings from the .mo file. Returns true on success.
|
|
|
|
bool readMoFile();
|
2007-01-14 09:55:08 +00:00
|
|
|
///
|
|
|
|
std::string lang_;
|
|
|
|
///
|
2013-05-08 16:50:38 +00:00
|
|
|
typedef std::map<std::string, docstring> TranslationMap;
|
|
|
|
TranslationMap trans_map_;
|
|
|
|
/// The language used by the Gui
|
|
|
|
static std::string gui_lang_;
|
2003-04-23 18:47:21 +00:00
|
|
|
};
|
|
|
|
|
2007-01-14 10:37:14 +00:00
|
|
|
/// Access to the unique Messages object for the passed \p language.
|
2007-04-26 04:41:58 +00:00
|
|
|
/// Implementation is in LyX.cpp.
|
2010-03-29 21:31:17 +00:00
|
|
|
extern Messages const & getMessages(std::string const & language);
|
2007-01-14 10:37:14 +00:00
|
|
|
/// Access to the unique Messages object used for GUI element.
|
2007-04-26 04:41:58 +00:00
|
|
|
/// Implementation is in LyX.cpp.
|
2010-03-29 21:31:17 +00:00
|
|
|
extern Messages const & getGuiMessages();
|
2007-01-14 10:37:14 +00:00
|
|
|
|
2012-04-10 18:21:01 +00:00
|
|
|
/// Remove the context suffix from \p trans
|
|
|
|
extern void cleanTranslation(docstring & trans);
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
#endif
|