]> git.lyx.org Git - lyx.git/blob - src/gettext.C
Alfredo's second patch
[lyx.git] / src / gettext.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #include "messages.h"
14 #include "LString.h"
15 #include "support/LAssert.h"
16
17 #include <boost/scoped_ptr.hpp>
18
19 #ifdef HAVE_LOCALE_H
20 #  include <locale.h>
21 #endif
22
23 namespace {
24
25 Messages & getLyXMessages()
26 {
27         static Messages lyx_messages;
28
29         return lyx_messages;
30 }
31
32 } // anon namespace
33
34
35 char const * _(char const * str)
36 {
37         return getLyXMessages().get(str).c_str();
38 }
39
40
41 string const _(string const & str)
42 {
43         return getLyXMessages().get(str);
44 }
45
46
47 #ifdef ENABLE_NLS
48
49 void locale_init()
50 {
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