2007-04-26 04:41:58 +00:00
|
|
|
/* \file Messages.cpp
|
2003-04-23 18:47:21 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2013-10-11 09:34:58 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
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
|
|
|
*/
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
/*
|
2013-10-11 09:34:58 +00:00
|
|
|
This contains a limited parser for gettext's mo files. Several features are
|
|
|
|
not implemented currently:
|
|
|
|
* encoding is supposed to be UTF-8 (the charset parameter is enforced)
|
2013-05-08 16:50:38 +00:00
|
|
|
* context is not handled (implemented differently in LyX)
|
2013-10-11 09:34:58 +00:00
|
|
|
* plural forms are not implemented (not used for now in LyX).
|
2013-05-08 16:50:38 +00:00
|
|
|
|
|
|
|
The data is loaded in a std::map object for simplicity.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Format of a MO file. Source: http://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
|
|
|
|
|
|
|
|
byte
|
|
|
|
+------------------------------------------+
|
|
|
|
0 | magic number = 0x950412de |
|
|
|
|
| |
|
|
|
|
4 | file format revision = 0 |
|
|
|
|
| |
|
|
|
|
8 | number of strings | == N
|
|
|
|
| |
|
|
|
|
12 | offset of table with original strings | == O
|
|
|
|
| |
|
|
|
|
16 | offset of table with translation strings | == T
|
|
|
|
| |
|
|
|
|
20 | size of hashing table | == S
|
|
|
|
| |
|
|
|
|
24 | offset of hashing table | == H
|
|
|
|
| |
|
|
|
|
. .
|
|
|
|
. (possibly more entries later) .
|
|
|
|
. .
|
|
|
|
| |
|
|
|
|
O | length & offset 0th string ----------------.
|
|
|
|
O + 8 | length & offset 1st string ------------------.
|
|
|
|
... ... | |
|
|
|
|
O + ((N-1)*8)| length & offset (N-1)th string | | |
|
|
|
|
| | | |
|
|
|
|
T | length & offset 0th translation ---------------.
|
|
|
|
T + 8 | length & offset 1st translation -----------------.
|
|
|
|
... ... | | | |
|
|
|
|
T + ((N-1)*8)| length & offset (N-1)th translation | | | | |
|
|
|
|
| | | | | |
|
|
|
|
H | start hash table | | | | |
|
|
|
|
... ... | | | |
|
|
|
|
H + S * 4 | end hash table | | | | |
|
|
|
|
| | | | | |
|
|
|
|
| NUL terminated 0th string <----------------' | | |
|
|
|
|
| | | | |
|
|
|
|
| NUL terminated 1st string <------------------' | |
|
|
|
|
| | | |
|
|
|
|
... ... | |
|
|
|
|
| | | |
|
|
|
|
| NUL terminated 0th translation <---------------' |
|
|
|
|
| | |
|
|
|
|
| NUL terminated 1st translation <-----------------'
|
|
|
|
| |
|
|
|
|
... ...
|
|
|
|
| |
|
|
|
|
+------------------------------------------+
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/Messages.h"
|
2007-01-14 09:55:08 +00:00
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/debug.h"
|
2007-01-14 09:55:08 +00:00
|
|
|
#include "support/docstring.h"
|
2010-12-03 17:48:06 +00:00
|
|
|
#include "support/lstrings.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
#include "support/Package.h"
|
2008-01-14 23:45:04 +00:00
|
|
|
#include "support/unicode.h"
|
2003-04-23 18:47:21 +00:00
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.h"
|
2004-10-19 09:11:02 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
#include <boost/cstdint.hpp>
|
|
|
|
|
2005-10-18 13:34:51 +00:00
|
|
|
#include <cerrno>
|
2013-05-08 16:50:38 +00:00
|
|
|
#include <fstream>
|
2013-10-11 09:34:58 +00:00
|
|
|
#include <utility>
|
2007-01-14 09:55:08 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
2012-07-15 20:22:10 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2013-05-08 16:50:38 +00:00
|
|
|
using boost::uint32_t;
|
2007-11-16 14:31:16 +00:00
|
|
|
|
2008-08-03 06:34:52 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
void cleanTranslation(docstring & trans)
|
2007-11-16 14:31:16 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
Some english words have different translations, depending on
|
|
|
|
context. In these cases the original string is augmented by
|
2012-07-15 22:27:58 +00:00
|
|
|
context information (e.g. "To:[[as in 'From page x to page
|
2013-10-11 09:34:58 +00:00
|
|
|
y']]" and "To:[[as in 'From format x to format y']]". Also,
|
2013-05-13 10:46:33 +00:00
|
|
|
when placeholders are used, the context can indicate what will
|
|
|
|
be substituted for the placeholder (e.g. "%1$s[[date]], %1$s
|
2013-10-11 09:34:58 +00:00
|
|
|
[[time]]). This means that we need to filter out everything
|
2013-05-13 10:46:33 +00:00
|
|
|
in double square brackets at the end of the string, otherwise
|
|
|
|
the user sees bogus messages. If we are unable to honour the
|
|
|
|
request we just return what we got in.
|
2007-11-16 14:31:16 +00:00
|
|
|
*/
|
2013-05-13 10:46:33 +00:00
|
|
|
static docstring const ctx_start = from_ascii("[[");
|
|
|
|
static docstring const ctx_end = from_ascii("]]");
|
|
|
|
while (true) {
|
|
|
|
size_t const pos1 = trans.find(ctx_start);
|
|
|
|
if (pos1 != docstring::npos) {
|
|
|
|
size_t const pos2 = trans.find(ctx_end, pos1);
|
|
|
|
if (pos2 != docstring::npos) {
|
|
|
|
trans.erase(pos1, pos2 - pos1 + 2);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2007-11-16 14:31:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-03 06:34:52 +00:00
|
|
|
} // lyx
|
2007-11-16 14:31:16 +00:00
|
|
|
|
|
|
|
|
2007-01-14 09:55:08 +00:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2007-12-12 18:57:56 +00:00
|
|
|
namespace lyx {
|
2006-11-12 11:06:02 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
std::string Messages::gui_lang_;
|
|
|
|
|
|
|
|
|
2007-01-14 09:55:08 +00:00
|
|
|
Messages::Messages(string const & l)
|
2013-05-02 14:38:25 +00:00
|
|
|
: lang_(l)
|
2007-01-14 09:55:08 +00:00
|
|
|
{
|
|
|
|
// strip off any encoding suffix, i.e., assume 8-bit po files
|
2007-11-29 21:10:35 +00:00
|
|
|
size_t i = lang_.find(".");
|
2007-01-14 09:55:08 +00:00
|
|
|
lang_ = lang_.substr(0, i);
|
2008-06-25 10:53:34 +00:00
|
|
|
LYXERR(Debug::LOCALE, "language(" << lang_ << ")");
|
2013-05-08 16:50:38 +00:00
|
|
|
|
|
|
|
readMoFile();
|
2007-01-14 09:55:08 +00:00
|
|
|
}
|
2006-11-12 11:06:02 +00:00
|
|
|
|
2003-04-23 18:47:21 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Find the code we have for a given language code. Return empty if not found.
|
2013-06-03 16:08:53 +00:00
|
|
|
string realCode(string code)
|
2013-05-08 16:50:38 +00:00
|
|
|
{
|
|
|
|
// this loops at most twice
|
|
|
|
while (true) {
|
2013-05-14 14:35:34 +00:00
|
|
|
if (package().messages_file(code).isReadableFile())
|
2013-05-08 16:50:38 +00:00
|
|
|
return code;
|
|
|
|
if (contains(code, '_'))
|
|
|
|
code = token(code, '_', 0);
|
|
|
|
else
|
|
|
|
break;
|
2007-01-14 09:55:08 +00:00
|
|
|
}
|
2013-05-08 16:50:38 +00:00
|
|
|
return string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-14 09:55:08 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
bool Messages::available(string const & c)
|
|
|
|
{
|
|
|
|
return !realCode(c).empty();
|
2012-07-15 20:22:10 +00:00
|
|
|
}
|
|
|
|
|
2008-07-28 11:26:46 +00:00
|
|
|
|
2012-07-15 20:22:10 +00:00
|
|
|
string Messages::language() const
|
|
|
|
{
|
2013-05-08 16:50:38 +00:00
|
|
|
return realCode(lang_);
|
2007-08-07 22:24:47 +00:00
|
|
|
}
|
|
|
|
|
2013-10-11 09:34:58 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void swapInt(uint32_t & number)
|
|
|
|
{
|
|
|
|
unsigned char * num_ar = reinterpret_cast<unsigned char *>(&number);
|
|
|
|
swap(num_ar[0], num_ar[3]);
|
|
|
|
swap(num_ar[1], num_ar[2]);
|
|
|
|
}
|
|
|
|
|
2007-08-07 22:24:47 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
struct MoHeader
|
2010-12-03 17:48:06 +00:00
|
|
|
{
|
2013-05-08 16:50:38 +00:00
|
|
|
// magic number = 0x950412de
|
|
|
|
uint32_t magic;
|
|
|
|
// file format revision = 0
|
|
|
|
uint32_t rev;
|
|
|
|
// number of strings
|
|
|
|
uint32_t N;
|
|
|
|
// offset of table with original strings
|
|
|
|
uint32_t O;
|
|
|
|
// offset of table with translation strings
|
|
|
|
uint32_t T;
|
2013-10-11 09:34:58 +00:00
|
|
|
// there is a hash table afterwards, but we ignore it
|
|
|
|
|
|
|
|
// Change the endianness of header data
|
|
|
|
void swapEnd();
|
2013-05-08 16:50:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-11 09:34:58 +00:00
|
|
|
void MoHeader::swapEnd()
|
|
|
|
{
|
|
|
|
swapInt(magic);
|
|
|
|
swapInt(rev);
|
|
|
|
swapInt(N);
|
|
|
|
swapInt(O);
|
|
|
|
swapInt(T);
|
|
|
|
}
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
struct StringTable
|
|
|
|
{
|
|
|
|
// string length
|
|
|
|
uint32_t length;
|
|
|
|
// string offset
|
|
|
|
uint32_t offset;
|
2013-10-11 09:34:58 +00:00
|
|
|
|
|
|
|
// Change the endianness of string stable data
|
|
|
|
void swapEnd();
|
2013-05-08 16:50:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-11 09:34:58 +00:00
|
|
|
void StringTable::swapEnd()
|
|
|
|
{
|
|
|
|
swapInt(length);
|
|
|
|
swapInt(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
bool Messages::readMoFile()
|
|
|
|
{
|
|
|
|
// FIXME:remove
|
|
|
|
if (lang_.empty()) {
|
|
|
|
LYXERR0("No language given, nothing to load.");
|
|
|
|
return false;
|
2012-08-23 13:08:21 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
string const code = realCode(lang_);
|
|
|
|
if (code.empty()) {
|
2014-05-06 12:29:42 +00:00
|
|
|
LYXERR(Debug::LOCALE, "Cannot find translation for language " << lang_);
|
2013-05-08 16:50:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-03 17:48:06 +00:00
|
|
|
|
2013-05-14 14:35:34 +00:00
|
|
|
string const filen = package().messages_file(code).toSafeFilesystemEncoding();
|
2013-02-05 13:19:33 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
// get file size
|
|
|
|
struct stat buf;
|
|
|
|
if (stat(filen.c_str(), &buf)) {
|
|
|
|
LYXERR0("Cannot get information for file " << filen);
|
|
|
|
return false;
|
2013-02-05 13:19:33 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
vector<char> moData(buf.st_size);
|
2013-02-05 13:19:33 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
ifstream is(filen.c_str(), ios::in | ios::binary);
|
|
|
|
if (!is.read(&moData[0], buf.st_size)) {
|
|
|
|
LYXERR0("Cannot read file " << filen);
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-05 13:19:33 +00:00
|
|
|
|
2013-10-11 09:34:58 +00:00
|
|
|
MoHeader * header = reinterpret_cast<MoHeader *>(&moData[0]);
|
|
|
|
|
|
|
|
bool doSwap = false;
|
|
|
|
if (header->magic == 0xde120495) {
|
|
|
|
header->swapEnd();
|
|
|
|
doSwap = true;
|
|
|
|
}
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
if (header->magic != 0x950412de) {
|
|
|
|
LYXERR0("Wrong magic number for file " << filen
|
2013-10-11 09:34:58 +00:00
|
|
|
<< ".\nExpected 0x950412de, got 0x" << std::hex << header->magic);
|
2013-05-08 16:50:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-11 09:34:58 +00:00
|
|
|
StringTable * orig = reinterpret_cast<StringTable *>(&moData[0] + header->O);
|
|
|
|
StringTable * trans = reinterpret_cast<StringTable *>(&moData[0] + header->T);
|
2013-05-08 16:50:38 +00:00
|
|
|
// First the header
|
2013-10-11 09:34:58 +00:00
|
|
|
if (doSwap) {
|
|
|
|
// Handle endiannness change
|
|
|
|
orig[0].swapEnd();
|
|
|
|
trans[0].swapEnd();
|
|
|
|
}
|
2013-05-08 16:50:38 +00:00
|
|
|
string const info = string(&moData[0] + trans[0].offset, trans[0].length);
|
|
|
|
size_t pos = info.find("charset=");
|
|
|
|
if (pos != string::npos) {
|
|
|
|
pos += 8;
|
|
|
|
string charset;
|
|
|
|
size_t pos2 = info.find("\n", pos);
|
|
|
|
if (pos2 == string::npos)
|
|
|
|
charset = info.substr(pos);
|
|
|
|
else
|
|
|
|
charset = info.substr(pos, pos2 - pos);
|
|
|
|
charset = ascii_lowercase(trim(charset));
|
|
|
|
if (charset != "utf-8") {
|
|
|
|
LYXERR0("Wrong encoding " << charset << " for file " << filen);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LYXERR0("Cannot find encoding encoding for file " << filen);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 1; i < header->N; ++i) {
|
2013-10-11 09:34:58 +00:00
|
|
|
if (doSwap) {
|
|
|
|
// Handle endiannness change
|
|
|
|
orig[i].swapEnd();
|
|
|
|
trans[i].swapEnd();
|
|
|
|
}
|
2013-05-08 16:50:38 +00:00
|
|
|
// Note that in theory the strings may contain NUL characters.
|
|
|
|
// This may be the case with plural forms
|
|
|
|
string const ostr(&moData[0] + orig[i].offset, orig[i].length);
|
|
|
|
docstring tstr = from_utf8(string(&moData[0] + trans[i].offset,
|
|
|
|
trans[i].length));
|
|
|
|
cleanTranslation(tstr);
|
|
|
|
trans_map_[ostr] = tstr;
|
|
|
|
//lyxerr << ostr << " ==> " << tstr << endl;
|
|
|
|
}
|
2013-02-05 13:19:33 +00:00
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-12-03 17:48:06 +00:00
|
|
|
|
2007-08-07 22:24:47 +00:00
|
|
|
docstring const Messages::get(string const & m) const
|
|
|
|
{
|
|
|
|
if (m.empty())
|
|
|
|
return docstring();
|
|
|
|
|
2013-05-08 16:50:38 +00:00
|
|
|
TranslationMap::const_iterator it = trans_map_.find(m);
|
|
|
|
if (it != trans_map_.end())
|
2007-08-07 22:24:47 +00:00
|
|
|
return it->second;
|
2013-05-08 16:50:38 +00:00
|
|
|
else {
|
|
|
|
docstring res = from_utf8(m);
|
|
|
|
cleanTranslation(res);
|
|
|
|
return res;
|
|
|
|
}
|
2007-01-14 09:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#else // ENABLE_NLS
|
|
|
|
// This is the dummy variant.
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2013-09-08 16:00:36 +00:00
|
|
|
std::string Messages::gui_lang_;
|
|
|
|
|
2010-09-06 06:14:25 +00:00
|
|
|
Messages::Messages(string const & /* l */) {}
|
2007-01-14 09:55:08 +00:00
|
|
|
|
|
|
|
docstring const Messages::get(string const & m) const
|
|
|
|
{
|
2007-11-16 14:31:16 +00:00
|
|
|
docstring trans = from_ascii(m);
|
|
|
|
cleanTranslation(trans);
|
|
|
|
return trans;
|
2007-01-14 09:55:08 +00:00
|
|
|
}
|
|
|
|
|
2012-09-23 13:07:41 +00:00
|
|
|
std::string Messages::language() const
|
2015-05-17 15:27:12 +00:00
|
|
|
{
|
|
|
|
return string();
|
|
|
|
}
|
2010-12-04 08:28:10 +00:00
|
|
|
|
2012-09-25 14:19:51 +00:00
|
|
|
bool Messages::available(string const & /* c */)
|
2010-12-04 08:28:10 +00:00
|
|
|
{
|
2010-12-04 17:42:38 +00:00
|
|
|
return false;
|
2010-12-04 08:28:10 +00:00
|
|
|
}
|
|
|
|
|
2007-01-14 09:55:08 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif
|