mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
7a7b9abf1b
The previous scheme of loading all possible translations and checking whether the work is a bit too much "brute force" and causes problems on Mac OS X (documents loaded with the wrong language). Now there is an helper static method in Messages class that checks whether a readable .mo file exist for the language. There should be an API in gettext for doing that, but alas it is not possible. As a consequence the method Language::translated() has been removed, along with its cache.
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
// -*- C++ -*-
|
|
/* \file Messages.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars Gullik Bjønnes
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef MESSAGES_H
|
|
#define MESSAGES_H
|
|
|
|
#include "support/docstring.h"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
namespace lyx {
|
|
|
|
///
|
|
class Messages {
|
|
public:
|
|
/// messages in the language \p l.
|
|
/// If \p l is empty, the language will be defined by the environment.
|
|
Messages(std::string const & l = std::string());
|
|
///
|
|
docstring const get(std::string const & msg) const;
|
|
/// What is the language associated with this translation?
|
|
std::string language() const;
|
|
/// Is an (at least partial) translation of language with code \p c available?
|
|
static bool available(std::string const & c);
|
|
///
|
|
static void init();
|
|
|
|
private:
|
|
///
|
|
std::string lang_;
|
|
/// Did we warn about unavailable locale already?
|
|
mutable bool warned_;
|
|
///
|
|
typedef std::map<std::string, docstring> TranslationCache;
|
|
/// Internal cache for gettext translated strings.
|
|
/// This is needed for performance reason within \c updateBuffer()
|
|
/// under Windows.
|
|
mutable TranslationCache cache_;
|
|
};
|
|
|
|
/// Access to the unique Messages object for the passed \p language.
|
|
/// Implementation is in LyX.cpp.
|
|
extern Messages const & getMessages(std::string const & language);
|
|
/// Access to the unique Messages object used for GUI element.
|
|
/// Implementation is in LyX.cpp.
|
|
extern Messages const & getGuiMessages();
|
|
|
|
/// Remove the context suffix from \p trans
|
|
extern void cleanTranslation(docstring & trans);
|
|
|
|
} // namespace lyx
|
|
|
|
#endif
|