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