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:
|
2007-01-14 09:55:08 +00:00
|
|
|
/// messages in the language \p l.
|
|
|
|
/// If \p l is empty, the language will be defined by the environment.
|
2007-08-07 22:24:47 +00:00
|
|
|
Messages(std::string const & l = std::string());
|
2003-04-23 18:47:21 +00:00
|
|
|
///
|
2007-01-14 09:55:08 +00:00
|
|
|
docstring const get(std::string const & msg) const;
|
2010-12-03 17:48:06 +00:00
|
|
|
/// Is an (at least partial) translation of this language available?
|
|
|
|
bool available() const;
|
2007-08-07 22:24:47 +00:00
|
|
|
///
|
|
|
|
static void init();
|
2008-07-28 11:26:46 +00:00
|
|
|
///
|
|
|
|
static std::string const & defaultLanguage() { return main_lang_; }
|
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
private:
|
2008-07-28 11:26:46 +00:00
|
|
|
///
|
|
|
|
static void setDefaultLanguage();
|
|
|
|
///
|
|
|
|
static std::string main_lang_;
|
2007-01-14 09:55:08 +00:00
|
|
|
///
|
|
|
|
std::string lang_;
|
2007-05-28 22:27:45 +00:00
|
|
|
/// Did we warn about unavailable locale already?
|
2007-02-24 22:54:19 +00:00
|
|
|
mutable bool warned_;
|
2007-01-14 09:55:08 +00:00
|
|
|
///
|
|
|
|
typedef std::map<std::string, docstring> TranslationCache;
|
|
|
|
/// Internal cache for gettext translated strings.
|
2010-03-03 22:13:45 +00:00
|
|
|
/// This is needed for performance reason within \c updateBuffer()
|
2007-01-14 09:55:08 +00:00
|
|
|
/// under Windows.
|
|
|
|
mutable TranslationCache cache_;
|
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
|