2003-05-19 21:08:58 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file src/gettext.cpp
|
2003-05-19 21:08:58 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-05-19 21:08:58 +00:00
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-19 21:08:58 +00:00
|
|
|
|
*/
|
2001-03-08 14:22:43 +00:00
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2003-09-05 16:31:30 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Messages.h"
|
2006-11-23 16:31:48 +00:00
|
|
|
|
|
2005-07-17 11:58:54 +00:00
|
|
|
|
#include "support/environment.h"
|
2006-11-23 16:31:48 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2003-04-24 22:09:46 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2001-10-31 12:43:09 +00:00
|
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
|
# include <locale.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::setEnv;
|
2006-09-09 15:27:44 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
docstring const _(string const & str)
|
2000-10-11 21:06:43 +00:00
|
|
|
|
{
|
2007-01-14 10:37:14 +00:00
|
|
|
|
return getGuiMessages().get(str);
|
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()
|
|
|
|
|
{
|
2005-07-17 11:58:54 +00:00
|
|
|
|
// Disable, as otherwise it overrides everything else incl. the doc language
|
|
|
|
|
setEnv("LANGUAGE", "");
|
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
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
2006-11-23 16:31:48 +00:00
|
|
|
|
docstring const translateIfPossible(docstring const & name)
|
|
|
|
|
{
|
|
|
|
|
if (support::isAscii(name))
|
|
|
|
|
// Probably from a standard configuration file, try to
|
|
|
|
|
// translate
|
|
|
|
|
return _(to_ascii(name));
|
|
|
|
|
else
|
|
|
|
|
// This must be from a user defined configuration file. We
|
|
|
|
|
// cannot translate this, since gettext accepts only ascii
|
|
|
|
|
// keys.
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|