]> git.lyx.org Git - lyx.git/blob - src/gettext.C
Continue to improve GtkLengthEntry
[lyx.git] / src / gettext.C
1 /**
2  * \file src/gettext.C
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 #include "support/environment.h"
17
18 #ifdef HAVE_LOCALE_H
19 #  include <locale.h>
20 #endif
21
22 using std::string;
23 using lyx::support::setEnv;
24
25
26 namespace {
27
28 Messages & getLyXMessages()
29 {
30         static Messages lyx_messages;
31
32         return lyx_messages;
33 }
34
35 } // anon namespace
36
37
38 string const _(string const & str)
39 {
40         return getLyXMessages().get(str);
41 }
42
43
44 #ifdef ENABLE_NLS
45
46 void locale_init()
47 {
48         // Disable, as otherwise it overrides everything else incl. the doc language
49         setEnv("LANGUAGE", "");
50 #  ifdef HAVE_LC_MESSAGES
51         setlocale(LC_MESSAGES, "");
52 #  endif
53         setlocale(LC_CTYPE, "");
54         setlocale(LC_NUMERIC, "C");
55 }
56
57 #else // ENABLE_NLS
58
59 void locale_init()
60 {
61         setlocale(LC_NUMERIC, "C");
62 }
63
64 #endif