2001-03-08 14:22:43 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-10-31 12:43:09 +00:00
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
2001-12-18 03:30:35 +00:00
|
|
|
#include <boost/smart_ptr.hpp>
|
|
|
|
|
2001-06-12 16:42:07 +00:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
|
2001-03-08 14:22:43 +00:00
|
|
|
# if HAVE_GETTEXT
|
|
|
|
# include <libintl.h> // use the header already in the system *EK*
|
|
|
|
# else
|
|
|
|
# include "../intl/libintl.h"
|
|
|
|
# endif
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
|
|
char const * _(char const * str)
|
|
|
|
{
|
2001-01-08 09:37:13 +00:00
|
|
|
// I'd rather have an Assert on str, we should not allow
|
|
|
|
// null pointers here. Lgb
|
|
|
|
// Assert(str);
|
2001-01-03 17:43:29 +00:00
|
|
|
if (str && str[0])
|
|
|
|
return gettext(str);
|
|
|
|
else
|
|
|
|
return "";
|
2000-10-11 21:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const _(string const & str)
|
|
|
|
{
|
2001-01-03 17:43:29 +00:00
|
|
|
if (!str.empty()) {
|
|
|
|
int const s = str.length();
|
2001-12-18 03:30:35 +00:00
|
|
|
boost::scoped_array<char> tmp(new char[s + 1]);
|
|
|
|
str.copy(tmp.get(), s);
|
2001-01-03 17:43:29 +00:00
|
|
|
tmp[s] = '\0';
|
2001-12-18 03:30:35 +00:00
|
|
|
string const ret(gettext(tmp.get()));
|
2001-01-03 17:43:29 +00:00
|
|
|
return ret;
|
2001-08-02 18:46:53 +00:00
|
|
|
} else {
|
2001-01-03 17:43:29 +00:00
|
|
|
return string();
|
2001-08-02 18:46:53 +00:00
|
|
|
}
|
2000-10-11 21:06:43 +00:00
|
|
|
}
|
2000-10-12 02:17:32 +00:00
|
|
|
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2001-03-08 14:22:43 +00:00
|
|
|
void locale_init()
|
|
|
|
{
|
|
|
|
# ifdef HAVE_LC_MESSAGES
|
|
|
|
setlocale(LC_MESSAGES, "");
|
2001-10-31 12:43:09 +00:00
|
|
|
# endif
|
2001-03-08 14:22:43 +00:00
|
|
|
setlocale(LC_CTYPE, "");
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
|
|
|
}
|
|
|
|
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2001-03-08 14:22:43 +00:00
|
|
|
void gettext_init(string const & localedir)
|
|
|
|
{
|
|
|
|
bindtextdomain(PACKAGE, localedir.c_str());
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
#else // ENABLE_NLS
|
|
|
|
|
|
|
|
void locale_init()
|
|
|
|
{
|
2001-10-31 15:19:49 +00:00
|
|
|
setlocale(LC_NUMERIC, "C");
|
2001-06-05 17:05:51 +00:00
|
|
|
}
|
|
|
|
|
2001-12-18 03:30:35 +00:00
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
void gettext_init(string const &)
|
|
|
|
{
|
|
|
|
}
|
2000-10-12 02:17:32 +00:00
|
|
|
#endif
|