src_client_header_files = Split('''
debug.h
- gettext.h
messages.h
''')
src_tex2lyx_header_files = Split('''
Spacing.h
context.h
- gettext.h
lyxfont.h
messages.h
tex2lyx.h
src/bufferparams.C
src/bufferview_funcs.C
src/client/debug.C
-src/client/gettext.h
src/converter.C
src/debug.C
src/exporter.C
src/insets/insetinclude.C
src/insets/insetindex.C
src/insets/insetmarginal.C
+src/insets/insetnomencl.C
src/insets/insetnote.C
src/insets/insetoptarg.C
src/insets/insetpagebreak.C
debug.C \
debug.h \
gettext.C \
- gettext.h \
messages.C \
messages.h
&& errorTags[i].level & level) {
// avoid _(...) re-entrance problem
// FIXME: should we use _() from gettext.h here?
- string const s = _(errorTags[i].desc);
- os << lyx::to_utf8(bformat(lyx::from_utf8(_("Debugging `%1$s' (%2$s)")),
+ lyx::docstring const s = _(errorTags[i].desc);
+ os << lyx::to_utf8(bformat(_("Debugging `%1$s' (%2$s)"),
lyx::from_utf8(errorTags[i].name),
- lyx::from_utf8(s)))
+ s))
<< '\n';
}
}
for (int i = 0; i < numErrorTags ; ++i)
os << setw(7) << static_cast<unsigned int>(errorTags[i].level)
<< setw(10) << errorTags[i].name
- << " " << _(errorTags[i].desc) << '\n';
+ << " " << lyx::to_utf8(_(errorTags[i].desc)) << '\n';
os.flush();
}
} // anon namespace
-string const _(string const & str)
+docstring const _(string const & str)
{
return getLyXMessages().get(str);
}
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file src/gettext.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author Jean-Marc Lasgouttes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef GETTEXT_H
-#define GETTEXT_H
-
-#include <string>
-
-
-namespace lyx {
-
-/*
- * Native Language Support
- *
- * The general idea is that any string that should be translated is handled
- * as follows:
- * _("string")
- *
- * Static strings are special, obviously and must be flagged as follows:
- * static str = N_("string");
- *
- * And wherever they are used:
- * _(str)
- *
- * Every file where there are strings needs:
- * #include "gettext.h"
- *
- * Remember to mention each of these files in "po/POFILES.in"
- *
- * The main() needs a locale_init() and a gettext_init() in the beginning.
- */
-
-/*
- * General translation notes:
- * Commands/options are not translated
- * Debug messages are not translated
- * Panic/fatal (that should not happen) messages need not be translated
- */
-
-
-//#ifdef ENABLE_NLS
-
-///
-std::string const _(std::string const &);
-
-//#else // ENABLE_NLS
-
-///
-//# define _(str) (str)
-
-//#endif
-
-# define N_(str) (str) // for detecting static strings
-
-///
-void locale_init();
-
-
-} // namespace lyx
-
-#endif
namespace lyx {
using lyx::support::package;
+using std::endl;
using std::string;
~Pimpl() {}
- string const get(string const & m) const
+ docstring const get(string const & m) const
{
if (m.empty())
- return m;
+ return from_ascii(m);
- char * old = strdup(setlocale(LC_ALL, 0));
+ char * o = setlocale(LC_ALL, 0);
+ string old;
+ if (o)
+ old = o;
char * n = setlocale(LC_ALL, lang_.c_str());
- bindtextdomain(PACKAGE, package().locale_dir().c_str());
+ if (!n)
+ // If we are unable to honour the request we just
+ // return what we got in.
+ return from_ascii(m);
+ errno = 0;
+ char const * c = bindtextdomain(PACKAGE, package().locale_dir().c_str());
+ int e = errno;
+ if (e) {
+ lyxerr[Debug::DEBUG]
+ << BOOST_CURRENT_FUNCTION << '\n'
+ << "Error code: " << errno << '\n'
+ << "Lang, mess: " << lang_ << " " << m << '\n'
+ << "Directory : " << package().locale_dir() << '\n'
+ << "Rtn value : " << c << endl;
+ }
+
+#ifdef WORDS_BIGENDIAN
+ static const char * codeset = "UCS-4BE";
+#else
+ static const char * codeset = "UCS-4LE";
+#endif
+ if (!bind_textdomain_codeset(PACKAGE, codeset)) {
+ lyxerr[Debug::DEBUG]
+ << BOOST_CURRENT_FUNCTION << '\n'
+ << "Error code: " << errno << '\n'
+ << "Codeset : " << codeset << '\n'
+ << endl;
+ }
+
textdomain(PACKAGE);
- const char* msg = gettext(m.c_str());
- setlocale(LC_ALL, old);
- free(old);
- // If we are unable to honour the request we just
- // return what we got in.
- return (!n ? m : string(msg));
+
+ char const * tmp = m.c_str();
+ char const * msg = gettext(tmp);
+ docstring translated;
+ if (!msg) {
+ lyxerr << "Undefined result from gettext" << endl;
+ translated = from_ascii(tmp);
+ } else if (msg == tmp) {
+ //lyxerr << "Same as entered returned" << endl;
+ translated = from_ascii(tmp);
+ } else {
+ lyxerr[Debug::DEBUG] << "We got a translation" << endl;
+ char_type const * ucs4 = reinterpret_cast<char_type const *>(msg);
+ translated = ucs4;
+ }
+ setlocale(LC_ALL, old.c_str());
+ return translated;
}
private:
///
~Pimpl() {}
- string const get(string const & m) const
+ docstring const get(string const & m) const
{
return m;
}
{}
-string const Messages::get(string const & msg) const
+docstring const Messages::get(string const & msg) const
{
return pimpl_->get(msg);
}
#ifndef MESSAGES_H
#define MESSAGES_H
+#include "support/docstring.h"
+
#include <boost/scoped_ptr.hpp>
-#include <string>
namespace lyx {
///
~Messages();
///
- std::string const get(std::string const & msg) const;
+ docstring const get(std::string const & msg) const;
private:
class Pimpl;
boost::scoped_ptr<Pimpl> pimpl_;
#include "gettext.h"
#include "messages.h"
#include "support/environment.h"
-#include "support/docstring.h"
namespace lyx {
#include "support/docstring.h"
-#include <string>
-
namespace lyx {
context.C \
context.h \
gettext.C \
- gettext.h \
lengthcommon.C \
lyxfont.C \
lyxfont.h \
namespace lyx {
-using std::string;
-
-string const _(string const & str)
+docstring const _(std::string const & str)
{
- return str;
+ return from_ascii(str);
}
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file tex2lyx/gettext.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author Jean-Marc Lasgouttes
- *
- * Full author contact details are available in file CREDITS.
- */
-#ifndef GETTEXT_H
-#define GETTEXT_H
-
-#include <string>
-
-
-namespace lyx {
-
-
-///
-std::string const _(std::string const &);
-
-/// for detecting static strings
-#define N_(str) (str)
-
-///
-void locale_init();
-
-
-} // namespace lyx
-
-#endif