]> git.lyx.org Git - lyx.git/blob - src/gettext.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / gettext.cpp
1 /**
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.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "gettext.h"
15 #include "Messages.h"
16
17 #include "support/lstrings.h"
18
19 #ifdef HAVE_LOCALE_H
20 #  include <locale.h>
21 #endif
22
23 using std::string;
24
25
26 namespace lyx {
27
28 docstring const _(string const & str)
29 {
30         return getGuiMessages().get(str);
31 }
32
33
34 void locale_init()
35 {
36 #ifdef ENABLE_NLS
37 #  ifdef HAVE_LC_MESSAGES
38         setlocale(LC_MESSAGES, "");
39 #  endif
40         setlocale(LC_CTYPE, "");
41         Messages::init();
42 #endif
43         setlocale(LC_NUMERIC, "C");
44 }
45
46
47 docstring const translateIfPossible(docstring const & name)
48 {
49         if (support::isAscii(name))
50                 // Probably from a standard configuration file, try to
51                 // translate
52                 return _(to_ascii(name));
53         else
54                 // This must be from a user defined configuration file. We
55                 // cannot translate this, since gettext accepts only ascii
56                 // keys.
57                 return name;
58 }
59
60
61 } // namespace lyx