]> git.lyx.org Git - lyx.git/commitdiff
Resolve link problems of tex2lyx and client by removing the extra gettext.h
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 4 Nov 2006 18:12:57 +0000 (18:12 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 4 Nov 2006 18:12:57 +0000 (18:12 +0000)
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

13 files changed:
development/scons/scons_manifest.py
po/POTFILES.in
src/client/Makefile.am
src/client/debug.C
src/client/gettext.C
src/client/gettext.h [deleted file]
src/client/messages.C
src/client/messages.h
src/gettext.C
src/gettext.h
src/tex2lyx/Makefile.am
src/tex2lyx/gettext.C
src/tex2lyx/gettext.h [deleted file]

index 5d48281b5b058eb2bf5a40caafd2fb84ae5e8fc5..0a042e1cad55036dc1b9ec664dd8f94f01031a3f 100644 (file)
@@ -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
index 7fd2c5ed1ed0757728c1fe2fbbcf19a8f42d43ce..076fb159f7e22b44b8f068890e528ee2033d64d5 100644 (file)
@@ -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
index e7a3bcbcbf6978c4f9e0815e36154c557994f189..6331ddfb4b773486eb7dd4418c46ff5391341554 100644 (file)
@@ -24,7 +24,6 @@ lyxclient_SOURCES = \
        debug.C \
        debug.h \
        gettext.C \
-       gettext.h \
        messages.C \
        messages.h
 
index c4c9165a02ad6b3702a8242ba001fa72106268b5..0afb657b37f85149614b312db0eef1f9fed320ac 100644 (file)
@@ -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<unsigned int>(errorTags[i].level)
                   << setw(10) << errorTags[i].name
-                  << "  " << _(errorTags[i].desc) << '\n';
+                  << "  " << lyx::to_utf8(_(errorTags[i].desc)) << '\n';
        os.flush();
 }
 
index 5770397d0ed1b8696faf4baca4ea7e6a1ebb208d..409b9271daba32e1445edeb4fcb37c637a9893be 100644 (file)
@@ -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 (file)
index 179d35b..0000000
+++ /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 <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
index 3cd43a11aeff062b42e8743e51b135a463c2a472..838d061b19c0db3503df32b8e8250141b597b496 100644 (file)
@@ -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<char_type const *>(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);
 }
index b79838cde2725e6ceb59590d948fa6147ad80dc9..b91001d22e65ed1c509a6c52af75c72070aa3259 100644 (file)
@@ -11,8 +11,9 @@
 #ifndef MESSAGES_H
 #define MESSAGES_H
 
+#include "support/docstring.h"
+
 #include <boost/scoped_ptr.hpp>
-#include <string>
 
 
 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> pimpl_;
index 6401bb616e777e9c813fdc338cd4ee0644672462..925e433363d50ab80972a4c4c70d3f5df129db64 100644 (file)
@@ -14,7 +14,6 @@
 #include "gettext.h"
 #include "messages.h"
 #include "support/environment.h"
-#include "support/docstring.h"
 
 
 namespace lyx {
index 724d6e4ea0fb9b2d371c4cbef176e22317b2d0e0..0783413b5eb6bd6a9ac8823201707180de15b480 100644 (file)
@@ -15,8 +15,6 @@
 
 #include "support/docstring.h"
 
-#include <string>
-
 
 namespace lyx {
 
index 37174b69c48227c8eb5a732452a6772c69fc285f..980f4ca1eee68e62b81b779424541a75a4d1a171 100644 (file)
@@ -42,7 +42,6 @@ tex2lyx_SOURCES = \
        context.C \
        context.h \
        gettext.C \
-       gettext.h \
        lengthcommon.C \
        lyxfont.C \
        lyxfont.h \
index 2f7436ac24e2fb955eec9aef6c142746378ab283..5758fc1b98a2f8ab8e07584883ee26908624eddb 100644 (file)
 
 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 (file)
index 9ef43d8..0000000
+++ /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 <string>
-
-
-namespace lyx {
-
-
-///
-std::string const _(std::string const &);
-
-/// for detecting static strings
-#define N_(str) (str)
-
-///
-void locale_init();
-
-
-} // namespace lyx
-
-#endif