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
22 // This version of the Pimpl utilizes the message capability of
23 // libstdc++ that is distributed with GNU G++
24 class Messages::Pimpl {
26 typedef std::messages<char>::catalog catalog;
28 Pimpl(string const & l, string const & dir)
29 : lang_(l), localedir_(dir),
30 loc_gl(lang_.c_str()),
31 mssg_gl(std::use_facet<std::messages<char> >(loc_gl))
33 //lyxerr << "Messages: language(" << l
34 // << ") in dir(" << dir << ")" << std::endl;
36 cat_gl = mssg_gl.open(PACKAGE, loc_gl, localedir_.c_str());
42 mssg_gl.close(cat_gl);
45 string const get(string const & msg) const
47 return mssg_gl.get(cat_gl, 0, 0, msg);
57 std::messages<char> const & mssg_gl;
68 # include <libintl.h> // use the header already in the system *EK*
70 # include "../intl/libintl.h"
73 // This is a more traditional variant.
74 class Messages::Pimpl {
76 Pimpl(string const & l, string const & dir)
77 : lang_(l), localedir_(dir)
79 //lyxerr << "Messages: language(" << l
80 // << ") in dir(" << dir << ")" << std::endl;
82 bindtextdomain(PACKAGE, localedir_.c_str());
88 string const get(string const & m) const
90 char * old = strdup(setlocale(LC_ALL, 0));
91 setlocale(LC_ALL, lang_.c_str());
92 const char* msg = gettext(m.c_str());
93 setlocale(LC_ALL, old);
106 // This is the dummy variant.
107 class Messages::Pimpl {
109 Pimpl(string const &, string const &) {}
113 string const get(string const & m) const
120 Messages::Messages(string const & l, string const & dir)
121 : pimpl_(new Pimpl(l, dir))
125 // We need this for the sake of scopted_ptr
126 Messages::~Messages()
130 string const Messages::get(string const & msg) const
132 return pimpl_->get(msg);