2 * \file src/gettext.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
9 * Full author contact details are available in file CREDITS.
14 #include "support/gettext.h"
16 #include "support/lstrings.h"
17 #include "support/Messages.h"
18 #include "support/Package.h"
28 docstring const _(string const & str)
30 return getGuiMessages().get(str);
37 # ifdef HAVE_LC_MESSAGES
38 setlocale(LC_MESSAGES, "");
40 setlocale(LC_CTYPE, "");
41 if (support::packageInitialized()) {
45 setlocale(LC_NUMERIC, "C");
49 docstring const translateIfPossible(docstring const & name)
51 if (support::isAscii(name) && !name.empty())
52 // Probably from a standard configuration file, try to
54 return _(to_ascii(name));
56 // This must be from a user defined configuration file. We
57 // cannot translate this, since gettext accepts only ascii
63 docstring const translateIfPossible(docstring const & name, std::string const & language)
65 if (support::isAscii(name) && !name.empty())
66 // Probably from a standard configuration file, try to
68 return getMessages(language).get(to_ascii(name));
70 // This must be from a user defined configuration file. We
71 // cannot translate this, since gettext accepts only ascii