From: Georg Baum Date: Sat, 4 Nov 2006 18:12:57 +0000 (+0000) Subject: Resolve link problems of tex2lyx and client by removing the extra gettext.h X-Git-Tag: 1.6.10~12039 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8cc9180ba8b606837a9e874014c8191cd85f9310;p=features.git Resolve link problems of tex2lyx and client by removing the extra gettext.h headers and converting the gettext stuff in tex2lyx and client to use docstring. The interface must be defined by src/gettext.h anyway, so better use that. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15740 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 5d48281b5b..0a042e1cad 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -981,7 +981,6 @@ src_frontends_qt4_files = Split(''' src_client_header_files = Split(''' debug.h - gettext.h messages.h ''') @@ -998,7 +997,6 @@ src_client_files = Split(''' src_tex2lyx_header_files = Split(''' Spacing.h context.h - gettext.h lyxfont.h messages.h tex2lyx.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 7fd2c5ed1e..076fb159f7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,7 +12,6 @@ src/bufferlist.C src/bufferparams.C src/bufferview_funcs.C src/client/debug.C -src/client/gettext.h src/converter.C src/debug.C src/exporter.C @@ -103,6 +102,7 @@ src/insets/insethfill.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 diff --git a/src/client/Makefile.am b/src/client/Makefile.am index e7a3bcbcbf..6331ddfb4b 100644 --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -24,7 +24,6 @@ lyxclient_SOURCES = \ debug.C \ debug.h \ gettext.C \ - gettext.h \ messages.C \ messages.h diff --git a/src/client/debug.C b/src/client/debug.C index c4c9165a02..0afb657b37 100644 --- a/src/client/debug.C +++ b/src/client/debug.C @@ -88,10 +88,10 @@ void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level) && 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'; } } @@ -104,7 +104,7 @@ void lyx_debug_trait::showTags(ostream & os) for (int i = 0; i < numErrorTags ; ++i) os << setw(7) << static_cast(errorTags[i].level) << setw(10) << errorTags[i].name - << " " << _(errorTags[i].desc) << '\n'; + << " " << lyx::to_utf8(_(errorTags[i].desc)) << '\n'; os.flush(); } diff --git a/src/client/gettext.C b/src/client/gettext.C index 5770397d0e..409b9271da 100644 --- a/src/client/gettext.C +++ b/src/client/gettext.C @@ -37,7 +37,7 @@ Messages & getLyXMessages() } // anon namespace -string const _(string const & str) +docstring const _(string const & str) { return getLyXMessages().get(str); } diff --git a/src/client/gettext.h b/src/client/gettext.h deleted file mode 100644 index 179d35bc9c..0000000000 --- a/src/client/gettext.h +++ /dev/null @@ -1,70 +0,0 @@ -// -*- 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 - - -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 diff --git a/src/client/messages.C b/src/client/messages.C index 3cd43a11ae..838d061b19 100644 --- a/src/client/messages.C +++ b/src/client/messages.C @@ -17,6 +17,7 @@ namespace lyx { using lyx::support::package; +using std::endl; using std::string; @@ -90,21 +91,63 @@ public: ~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(msg); + translated = ucs4; + } + setlocale(LC_ALL, old.c_str()); + return translated; } private: /// @@ -120,7 +163,7 @@ public: ~Pimpl() {} - string const get(string const & m) const + docstring const get(string const & m) const { return m; } @@ -143,7 +186,7 @@ Messages::~Messages() {} -string const Messages::get(string const & msg) const +docstring const Messages::get(string const & msg) const { return pimpl_->get(msg); } diff --git a/src/client/messages.h b/src/client/messages.h index b79838cde2..b91001d22e 100644 --- a/src/client/messages.h +++ b/src/client/messages.h @@ -11,8 +11,9 @@ #ifndef MESSAGES_H #define MESSAGES_H +#include "support/docstring.h" + #include -#include namespace lyx { @@ -27,7 +28,7 @@ public: /// ~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_; diff --git a/src/gettext.C b/src/gettext.C index 6401bb616e..925e433363 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -14,7 +14,6 @@ #include "gettext.h" #include "messages.h" #include "support/environment.h" -#include "support/docstring.h" namespace lyx { diff --git a/src/gettext.h b/src/gettext.h index 724d6e4ea0..0783413b5e 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -15,8 +15,6 @@ #include "support/docstring.h" -#include - namespace lyx { diff --git a/src/tex2lyx/Makefile.am b/src/tex2lyx/Makefile.am index 37174b69c4..980f4ca1ee 100644 --- a/src/tex2lyx/Makefile.am +++ b/src/tex2lyx/Makefile.am @@ -42,7 +42,6 @@ tex2lyx_SOURCES = \ context.C \ context.h \ gettext.C \ - gettext.h \ lengthcommon.C \ lyxfont.C \ lyxfont.h \ diff --git a/src/tex2lyx/gettext.C b/src/tex2lyx/gettext.C index 2f7436ac24..5758fc1b98 100644 --- a/src/tex2lyx/gettext.C +++ b/src/tex2lyx/gettext.C @@ -16,12 +16,10 @@ namespace lyx { -using std::string; - -string const _(string const & str) +docstring const _(std::string const & str) { - return str; + return from_ascii(str); } diff --git a/src/tex2lyx/gettext.h b/src/tex2lyx/gettext.h deleted file mode 100644 index 9ef43d8d0c..0000000000 --- a/src/tex2lyx/gettext.h +++ /dev/null @@ -1,33 +0,0 @@ -// -*- 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 - - -namespace lyx { - - -/// -std::string const _(std::string const &); - -/// for detecting static strings -#define N_(str) (str) - -/// -void locale_init(); - - -} // namespace lyx - -#endif