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