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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjø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>
|
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/gettext.h"
|
2006-11-23 16:31:48 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/Messages.h"
|
2011-03-29 22:18:21 +00:00
|
|
|
#include "support/Package.h"
|
2003-04-24 22:09:46 +00:00
|
|
|
|
2001-10-31 12:43:09 +00:00
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
# include <locale.h>
|
|
|
|
#endif
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
void locale_init()
|
|
|
|
{
|
2007-08-07 22:24:47 +00:00
|
|
|
#ifdef ENABLE_NLS
|
2003-04-24 22:09:46 +00:00
|
|
|
# ifdef HAVE_LC_MESSAGES
|
|
|
|
setlocale(LC_MESSAGES, "");
|
|
|
|
# endif
|
|
|
|
setlocale(LC_CTYPE, "");
|
2011-05-06 19:24:54 +00:00
|
|
|
Messages::init();
|
2007-08-07 22:24:47 +00:00
|
|
|
#endif
|
2001-10-31 15:19:49 +00:00
|
|
|
setlocale(LC_NUMERIC, "C");
|
2001-06-05 17:05:51 +00:00
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2006-11-23 16:31:48 +00:00
|
|
|
docstring const translateIfPossible(docstring const & name)
|
|
|
|
{
|
2009-07-12 14:50:51 +00:00
|
|
|
if (support::isAscii(name) && !name.empty())
|
2006-11-23 16:31:48 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-09 18:16:43 +00:00
|
|
|
docstring const translateIfPossible(docstring const & name, std::string const & language)
|
|
|
|
{
|
2009-07-12 14:50:51 +00:00
|
|
|
if (support::isAscii(name) && !name.empty())
|
2009-06-09 18:16:43 +00:00
|
|
|
// Probably from a standard configuration file, try to
|
|
|
|
// translate
|
|
|
|
return getMessages(language).get(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
|