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