mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-16 07:55:41 +00:00
30ec879d3a
This reuses code intended only for mac manus and generalizes it. The list of strings to add to po files is found in GuiTranslator::translate. This is useful now that LyX relies on QDialogButtonBox class for its dialogs. Indeed many languages are not covered natively by Qt. It is possible to enable the "locace" debug channel to see what strings are not covered and should be added to our own translation tables. In order to make things easier, a new method getIfFound() has been added to the Messages class, which returns an empty string when no translation has been found, as Qt's translate() does.
67 lines
1.8 KiB
C++
67 lines
1.8 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:
|
|
/// dummy instantiation: no translation is done
|
|
Messages() {}
|
|
/// messages in the language \p l.
|
|
Messages(std::string const & l);
|
|
/// Return the tranlation of message \c msg, or the original
|
|
/// string if no context was found. Context is always removed.
|
|
docstring const get(std::string const & msg) const;
|
|
///
|
|
docstring const getIfFound(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 guiLanguage(std::string const & l) { gui_lang_ = l; }
|
|
///
|
|
static std::string const & guiLanguage() { return gui_lang_; }
|
|
|
|
private:
|
|
/// Read the strings from the .mo file. Returns true on success.
|
|
bool readMoFile();
|
|
///
|
|
std::string lang_;
|
|
///
|
|
typedef std::map<std::string, docstring> TranslationMap;
|
|
TranslationMap trans_map_;
|
|
/// The language used by the Gui
|
|
static std::string gui_lang_;
|
|
};
|
|
|
|
/// 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
|