2001-03-08 14:22:43 +00:00
|
|
|
/* This file is part of
|
2002-03-21 17:27:08 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
2001-03-08 14:22:43 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2001-03-08 14:22:43 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
#include "messages.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include "support/LAssert.h"
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2001-10-31 12:43:09 +00:00
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
namespace {
|
2000-10-11 21:06:43 +00:00
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
boost::scoped_ptr<Messages> lyx_messages;
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
} // anon namespace
|
2001-06-12 16:42:07 +00:00
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
|
|
char const * _(char const * str)
|
|
|
|
{
|
2003-04-24 22:09:46 +00:00
|
|
|
lyx::Assert(str && str[0]);
|
|
|
|
|
|
|
|
if (!lyx_messages.get())
|
|
|
|
return str;
|
|
|
|
|
|
|
|
return lyx_messages->get(str).c_str();
|
2000-10-11 21:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
string const _(string const & str)
|
2000-10-11 21:06:43 +00:00
|
|
|
{
|
2003-04-24 22:09:46 +00:00
|
|
|
lyx::Assert(!str.empty());
|
2000-10-12 02:17:32 +00:00
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
if (!lyx_messages.get())
|
|
|
|
return str;
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
return lyx_messages->get(str);
|
2001-03-08 14:22:43 +00:00
|
|
|
}
|
|
|
|
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2001-03-08 14:22:43 +00:00
|
|
|
void gettext_init(string const & localedir)
|
|
|
|
{
|
2003-04-24 22:09:46 +00:00
|
|
|
lyx_messages.reset(new Messages("", localedir));
|
2001-03-08 14:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
#ifdef ENABLE_NLS
|
2001-06-05 17:05:51 +00:00
|
|
|
|
|
|
|
void locale_init()
|
|
|
|
{
|
2003-04-24 22:09:46 +00:00
|
|
|
# ifdef HAVE_LC_MESSAGES
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
# endif
|
|
|
|
setlocale(LC_CTYPE, "");
|
2001-10-31 15:19:49 +00:00
|
|
|
setlocale(LC_NUMERIC, "C");
|
2001-06-05 17:05:51 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
#else // ENABLE_NLS
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2003-04-24 22:09:46 +00:00
|
|
|
void locale_init()
|
2001-06-05 17:05:51 +00:00
|
|
|
{
|
2003-04-24 22:09:46 +00:00
|
|
|
setlocale(LC_NUMERIC, "C");
|
2001-06-05 17:05:51 +00:00
|
|
|
}
|
2003-04-24 22:09:46 +00:00
|
|
|
|
2000-10-12 02:17:32 +00:00
|
|
|
#endif
|