mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
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
This commit is contained in:
parent
e35725d5c0
commit
8cc9180ba8
@ -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
|
||||
|
@ -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
|
||||
|
@ -24,7 +24,6 @@ lyxclient_SOURCES = \
|
||||
debug.C \
|
||||
debug.h \
|
||||
gettext.C \
|
||||
gettext.h \
|
||||
messages.C \
|
||||
messages.h
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ Messages & getLyXMessages()
|
||||
} // anon namespace
|
||||
|
||||
|
||||
string const _(string const & str)
|
||||
docstring const _(string const & str)
|
||||
{
|
||||
return getLyXMessages().get(str);
|
||||
}
|
||||
|
@ -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
|
@ -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());
|
||||
textdomain(PACKAGE);
|
||||
const char* msg = gettext(m.c_str());
|
||||
setlocale(LC_ALL, old);
|
||||
free(old);
|
||||
if (!n)
|
||||
// If we are unable to honour the request we just
|
||||
// return what we got in.
|
||||
return (!n ? m : string(msg));
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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_;
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "gettext.h"
|
||||
#include "messages.h"
|
||||
#include "support/environment.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
@ -42,7 +42,6 @@ tex2lyx_SOURCES = \
|
||||
context.C \
|
||||
context.h \
|
||||
gettext.C \
|
||||
gettext.h \
|
||||
lengthcommon.C \
|
||||
lyxfont.C \
|
||||
lyxfont.h \
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user