2 * This file is part of LyX, the document processor.
3 * Licence details can be found in the file COPYING.
5 * \author Lars Gullik Bjønnes
7 * Full author contact details are available in file CREDITS.
13 #include "support/filetools.h"
14 #include "support/path_defines.h"
16 using lyx::support::GetEnvPath;
17 using lyx::support::lyx_localedir;
29 // This version of the Pimpl utilizes the message capability of
30 // libstdc++ that is distributed with GNU G++.
31 class Messages::Pimpl {
33 typedef std::messages<char>::catalog catalog;
35 Pimpl(string const & l)
37 loc_gl(lang_.c_str()),
38 mssg_gl(std::use_facet<std::messages<char> >(loc_gl))
40 //lyxerr << "Messages: language(" << l
41 // << ") in dir(" << dir << ")" << std::endl;
43 cat_gl = mssg_gl.open(PACKAGE, loc_gl, lyx_localedir().c_str());
49 mssg_gl.close(cat_gl);
52 string const get(string const & msg) const
54 return mssg_gl.get(cat_gl, 0, 0, msg);
62 std::messages<char> const & mssg_gl;
73 # include <libintl.h> // use the header already in the system *EK*
75 # include "../intl/libintl.h"
78 // This is a more traditional variant.
79 class Messages::Pimpl {
81 Pimpl(string const & l)
84 //lyxerr << "Messages: language(" << l
85 // << ") in dir(" << dir << ")" << std::endl;
91 string const get(string const & m) const
96 char * old = strdup(setlocale(LC_ALL, 0));
97 char * n = setlocale(LC_ALL, lang_.c_str());
98 bindtextdomain(PACKAGE, lyx_localedir().c_str());
100 const char* msg = gettext(m.c_str());
101 setlocale(LC_ALL, old);
103 // If we are unable to honour the request we just
104 // return what we got in.
105 return (!n ? m : string(msg));
114 // This is the dummy variant.
115 class Messages::Pimpl {
117 Pimpl(string const &) {}
121 string const get(string const & m) const
130 : pimpl_(new Pimpl(""))
134 Messages::Messages(string const & l)
135 : pimpl_(new Pimpl(l))
139 // We need this for the sake of scoped_ptr
140 Messages::~Messages()
144 string const Messages::get(string const & msg) const
146 return pimpl_->get(msg);