}
-string const Buffer::B_(string const & l10n) const
+docstring const Buffer::B_(string const & l10n) const
{
if (pimpl_->messages.get()) {
return pimpl_->messages->get(l10n);
}
- return _(l10n);
+ // FIXME UNICODE When _() is changed to return a docstring
+ // the from_utf8 can be removed
+ return lyx::from_utf8(_(l10n));
}
if (full_source) {
os << "% Preview source code\n\n";
- if (isLatex())
+ if (isLatex())
writeLaTeXSource(os, filePath(), runparams, true, true);
- else
+ else
writeDocBookSource(os, fileName(), runparams, false);
} else {
runparams.par_begin = par_begin;
#include "support/limited_stack.h"
#include "support/types.h"
+#include "support/docstring.h"
#include <boost/scoped_ptr.hpp>
#include <boost/signal.hpp>
/// returns the main language for the buffer (document)
Language const * getLanguage() const;
/// get l10n translated to the buffers language
- std::string const B_(std::string const & l10n) const;
+ lyx::docstring const B_(std::string const & l10n) const;
///
int runChktex();
break;
}
- par.params().labelString(counters.counterLabel(buf.B_(format)));
+ // FIXME UNICODE
+ par.params().labelString(counters.counterLabel(lyx::to_utf8(buf.B_(format))));
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
counters.step("bibitem");
int number = counters.value("bibitem");
if (par.bibitem())
par.bibitem()->setCounter(number);
- par.params().labelString(buf.B_(layout->labelstring()));
+ // FIXME UNICODE
+ par.params().labelString(lyx::to_utf8(buf.B_(layout->labelstring())));
// In biblio should't be following counters but...
} else if (layout->labeltype == LABEL_SENSITIVE) {
// Search for the first float or wrap inset in the iterator
counters.step(fl.type());
// Doesn't work... yet.
- s = bformat(_("%1$s #:"), buf.B_(fl.name()));
+ // FIXME UNICODE
+ s = bformat(_("%1$s #:"), lyx::to_utf8(buf.B_(fl.name())));
} else {
// par->SetLayout(0);
- s = buf.B_(layout->labelstring());
+ // FIXME UNICODE
+ s = lyx::to_utf8(buf.B_(layout->labelstring()));
}
par.params().labelString(s);
} else if (layout->labeltype == LABEL_NO_LABEL)
par.params().labelString(string());
else
- par.params().labelString(buf.B_(layout->labelstring()));
+ // FIXME UNICODE
+ par.params().labelString(lyx::to_utf8(buf.B_(layout->labelstring())));
}
} // anon namespace
-bool updateCurrentLabel(Buffer const & buf,
- ParIterator & it)
+bool updateCurrentLabel(Buffer const & buf,
+ ParIterator & it)
{
if (it == par_iterator_end(buf.inset()))
- return false;
+ return false;
// if (it.lastpit == 0 && LyXText::isMainText())
// return false;
switch (it->layout()->labeltype) {
-
+
case LABEL_NO_LABEL:
case LABEL_MANUAL:
case LABEL_BIBLIO:
}
-void updateLabels(Buffer const & buf,
+void updateLabels(Buffer const & buf,
ParIterator & from, ParIterator & to)
{
for (ParIterator it = from; it != to; ++it) {
}
-void updateLabels(Buffer const & buf,
+void updateLabels(Buffer const & buf,
ParIterator & iter)
{
if (updateCurrentLabel(buf, iter))
{
// start over the counters
buf.params().getLyXTextClass().counters().reset();
-
+
ParIterator const end = par_iterator_end(buf.inset());
for (ParIterator it = par_iterator_begin(buf.inset()); it != end; ++it) {
{
LyXTextClass const & tclass = buf.params().getLyXTextClass();
- string fmt = buf.B_(appendix ? layout->labelstring_appendix()
- : layout->labelstring());
+ // FIXME UNICODE
+ string fmt = lyx::to_utf8(buf.B_(appendix ? layout->labelstring_appendix()
+ : layout->labelstring()));
// handle 'inherited level parts' in 'fmt',
// i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
#include "gettext.h"
#include "messages.h"
#include "support/environment.h"
+#include "support/docstring.h"
#ifdef HAVE_LOCALE_H
# include <locale.h>
string const _(string const & str)
{
- return getLyXMessages().get(str);
+ return lyx::to_utf8(getLyXMessages().get(str));
}
FloatList const & floats = buf.params().getLyXTextClass().floats();
FloatList::const_iterator it = floats[getCmdName()];
if (it != floats.end())
- return buf.B_(it->second.listName());
+ // FIXME UNICODE
+ return lyx::to_utf8(buf.B_(it->second.listName()));
else
return _("ERROR: Nonexistent float type!");
}
os << "%% unknown builtin float\n";
}
} else {
+ // FIXME UNICODE
os << "\\listof{" << getCmdName() << "}{"
- << buf.B_(cit->second.listName()) << "}\n";
+ << lyx::to_utf8(buf.B_(cit->second.listName())) << "}\n";
}
} else {
os << "%%\\listof{" << getCmdName() << "}{"
#include "support/filetools.h"
#include "support/environment.h"
#include "support/package.h"
+#include "support/docstring.h"
+#include "support/types.h"
#include <boost/current_function.hpp>
#include <boost/regex.hpp>
using lyx::support::getEnv;
using lyx::support::setEnv;
-using std::string;
+using lyx::char_type;
+using lyx::docstring;
+using lyx::from_ascii;
+using std::string;
+using std::endl;
#ifdef ENABLE_NLS
mssg_gl(std::use_facet<std::messages<char> >(loc_gl))
{
//lyxerr << "Messages: language(" << l
- // << ") in dir(" << dir << ")" << std::endl;
+ // << ") in dir(" << dir << ")" << endl;
cat_gl = mssg_gl.open(PACKAGE, loc_gl, package().locale_dir().c_str());
mssg_gl.close(cat_gl);
}
- string const get(string const & msg) const
+ docstring const get(string const & msg) const
{
return mssg_gl.get(cat_gl, 0, 0, msg);
}
string::size_type i = lang_.find(".");
lang_ = lang_.substr(0, i);
lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
- << ": language(" << lang_ << ")" << std::endl;
+ << ": language(" << lang_ << ")" << endl;
}
~Pimpl() {}
- string const get(string const & m) const
+ docstring const get(string const & m) const
{
if (m.empty())
- return m;
+ return lyx::from_ascii(m);
// In this order, see support/filetools.C:
string lang = getEnv("LC_ALL");
static bool warned = false;
if (!warned && !lc_msgs) {
warned = true;
- lyxerr << "Locale " << lang_ << " could not be set" << std::endl;
+ lyxerr << "Locale " << lang_ << " could not be set" << endl;
}
#endif
// CTYPE controls what getmessage thinks what encoding the po file uses
<< "Error code: " << errno << '\n'
<< "Lang, mess: " << lang_ << " " << m << '\n'
<< "Directory : " << package().locale_dir() << '\n'
- << "Rtn value : " << c << std::endl;
+ << "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);
+#if 0
const char* msg = gettext(m.c_str());
string translated(msg ? msg : m);
// Some english words have different translations, depending
boost::smatch sub;
if (regex_match(translated, sub, reg))
translated = sub.str(1);
+#else
+ 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 << "We got a translation" << endl;
+ lyx::char_type const * ucs4 = reinterpret_cast<lyx::char_type const *>(msg);
+ translated = ucs4;
+ }
+#endif
#ifdef HAVE_LC_MESSAGES
setlocale(LC_MESSAGES, lang.c_str());
#endif
{}
-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>
///
~Messages();
///
- std::string const get(std::string const & msg) const;
+ lyx::docstring const get(std::string const & msg) const;
private:
class Pimpl;
boost::scoped_ptr<Pimpl> pimpl_;