A bunch of conversion to docstring.

- bformat(): contributed by Georg Beaum
- Alert::XXX
- error(): in SpellBase, ispell, psell, aspell, buffer, etc.
- message(), message signal
- displayMessage(), setMessage,
- ErrorItems
- prettyName()
- makeDisplayPath()

and maybe some more...


- etc... 

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14970 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-09-11 08:54:10 +00:00
parent 189d298d96
commit a6444784dc
108 changed files with 922 additions and 851 deletions

View File

@ -437,9 +437,9 @@ string const abs_path_from_binary_name(string const & exe)
string const abs_binary = get_binary_path(exe);
if (abs_binary.empty()) {
// FIXME UNICODE
lyxerr << bformat(lyx::to_utf8(_("Unable to determine the path to the "
"LyX binary from the command line %1$s")),
exe)
lyxerr << lyx::to_utf8(bformat(_("Unable to determine the path to the "
"LyX binary from the command line %1$s"),
lyx::from_utf8(exe)))
<< std::endl;
bail_out();
}
@ -559,14 +559,14 @@ get_system_support_dir(string const & abs_binary,
}
// FIXME UNICODE
lyxerr << bformat(lyx::to_utf8(_("Unable to determine the system directory "
lyxerr << lyx::to_utf8(bformat(_("Unable to determine the system directory "
"having searched\n"
"\t%1$s\n"
"Use the '-sysdir' command line parameter or "
"set the environment variable LYX_DIR_14x to "
"the LyX system directory containing the file "
"`chkconfig.ltx'.")),
searched_dirs_str)
"`chkconfig.ltx'."),
lyx::from_utf8(searched_dirs_str)))
<< std::endl;
bail_out();
@ -645,9 +645,10 @@ bool check_command_line_dir(string const & dir,
string const abs_path = fileSearch(dir, file);
if (abs_path.empty()) {
// FIXME UNICODE
lyxerr << bformat(lyx::to_utf8(_("Invalid %1$s switch.\n"
"Directory %2$s does not contain %3$s.")),
command_line_switch, dir, file)
lyxerr << lyx::to_utf8(bformat(_("Invalid %1$s switch.\n"
"Directory %2$s does not contain %3$s."),
lyx::from_utf8(command_line_switch), lyx::from_utf8(dir),
lyx::from_utf8(file)))
<< std::endl;
}
@ -672,9 +673,9 @@ bool check_env_var_dir(string const & dir,
string const abs_path = fileSearch(dir, file);
if (abs_path.empty()) {
// FIXME UNICODE
lyxerr << bformat(lyx::to_utf8(_("Invalid %1$s environment variable.\n"
"Directory %2$s does not contain %3$s.")),
env_var, dir, file)
lyxerr << lyx::to_utf8(bformat(_("Invalid %1$s environment variable.\n"
"Directory %2$s does not contain %3$s."),
lyx::from_utf8(env_var), lyx::from_utf8(dir), lyx::from_utf8(file)))
<< std::endl;
}
@ -695,10 +696,10 @@ bool check_env_var_dir(string const & dir,
// package.C.in as a file containing strings that need
// translation.
// FIXME UNICODE
string const fmt =
lyx::to_utf8(_("Invalid %1$s environment variable.\n%2$s is not a directory."));
docstring const fmt =
_("Invalid %1$s environment variable.\n%2$s is not a directory.");
lyxerr << bformat(fmt, env_var, dir)
lyxerr << lyx::to_utf8(bformat(fmt, lyx::from_utf8(env_var), lyx::from_utf8(dir)))
<< std::endl;
}

View File

@ -218,7 +218,7 @@ public:
void updateMetrics(bool singlepar = false);
/// This signal is emitted when some message shows up.
boost::signal<void(std::string)> message;
boost::signal<void(lyx::docstring)> message;
private:
///

View File

@ -160,12 +160,12 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
// File already open?
if (bufferlist.exists(s)) {
string const file = makeDisplayPath(s, 20);
string text = bformat(lyx::to_utf8(_("The document %1$s is already "
docstring const file = makeDisplayPath(s, 20);
docstring text = bformat(_("The document %1$s is already "
"loaded.\n\nDo you want to revert "
"to the saved version?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Revert to saved document?")),
text, 0, 1, lyx::to_utf8(_("&Revert")), lyx::to_utf8(_("&Switch to document")));
"to the saved version?"), file);
int const ret = Alert::prompt(_("Revert to saved document?"),
text, 0, 1, _("&Revert"), _("&Switch to document"));
if (ret != 0) {
setBuffer(bufferlist.getBuffer(s));
@ -186,11 +186,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
return false;
}
} else {
string text = bformat(lyx::to_utf8(_("The document %1$s does not yet "
docstring text = bformat(_("The document %1$s does not yet "
"exist.\n\nDo you want to create "
"a new document?")), s);
int const ret = Alert::prompt(lyx::to_utf8(_("Create new document?")),
text, 0, 1, lyx::to_utf8(_("&Create")), lyx::to_utf8(_("Cancel")));
"a new document?"), lyx::from_utf8(s));
int const ret = Alert::prompt(_("Create new document?"),
text, 0, 1, _("&Create"), _("Cancel"));
if (ret == 0) {
b = newFile(s, string(), true);
@ -604,7 +604,7 @@ void BufferView::Pimpl::savePosition(unsigned int i)
cursor_.pos());
if (i > 0)
// emit message signal.
bv_->message(bformat(lyx::to_utf8(_("Saved bookmark %1$d")), i));
bv_->message(bformat(_("Saved bookmark %1$d"), i));
}
@ -638,7 +638,7 @@ void BufferView::Pimpl::restorePosition(unsigned int i)
if (i > 0)
// emit message signal.
bv_->message(bformat(lyx::to_utf8(_("Moved to bookmark %1$d")), i));
bv_->message(bformat(_("Moved to bookmark %1$d"), i));
}
@ -728,7 +728,7 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
// check selected filename
if (filename.empty()) {
// emit message signal.
bv_->message(lyx::to_utf8(_("Canceled.")));
bv_->message(_("Canceled."));
return;
}
}
@ -737,11 +737,11 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
// to the filename if necessary
filename = fileSearch(string(), filename, "lyx");
string const disp_fn = makeDisplayPath(filename);
docstring const disp_fn = makeDisplayPath(filename);
// emit message signal.
bv_->message(bformat(lyx::to_utf8(_("Inserting document %1$s...")), disp_fn));
bv_->message(bformat(_("Inserting document %1$s..."), disp_fn));
string res;
docstring res;
Buffer buf("", false);
if (::loadLyXFile(&buf, makeAbsPath(filename))) {
ErrorList & el = buffer_->errorList("Parse");
@ -749,9 +749,9 @@ void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
el = buf.errorList("Parse");
lyx::cap::pasteParagraphList(cursor_, buf.paragraphs(),
buf.params().textclass, el);
res = lyx::to_utf8(_("Document %1$s inserted."));
res = _("Document %1$s inserted.");
} else
res = lyx::to_utf8(_("Could not insert document %1$s"));
res = _("Could not insert document %1$s");
// emit message signal.
bv_->message(bformat(res, disp_fn));
@ -957,10 +957,10 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
case LFUN_UNDO:
if (available()) {
cur.message(lyx::to_utf8(_("Undo")));
cur.message(_("Undo"));
cur.clearSelection();
if (!textUndo(*bv_))
cur.message(lyx::to_utf8(_("No further undo information")));
cur.message(_("No further undo information"));
update();
switchKeyMap();
}
@ -968,10 +968,10 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
case LFUN_REDO:
if (available()) {
cur.message(lyx::to_utf8(_("Redo")));
cur.message(_("Redo"));
cur.clearSelection();
if (!textRedo(*bv_))
cur.message(lyx::to_utf8(_("No further redo information")));
cur.message(_("No further redo information"));
update();
switchKeyMap();
}
@ -993,7 +993,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
break;
case LFUN_FONT_STATE:
cur.message(cur.currentState());
cur.message(lyx::from_utf8(cur.currentState()));
break;
case LFUN_BOOKMARK_SAVE:
@ -1119,24 +1119,24 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
case LFUN_MARK_OFF:
cur.clearSelection();
cur.resetAnchor();
cur.message(N_("Mark off"));
cur.message(lyx::from_utf8(N_("Mark off")));
break;
case LFUN_MARK_ON:
cur.clearSelection();
cur.mark() = true;
cur.resetAnchor();
cur.message(N_("Mark on"));
cur.message(lyx::from_utf8(N_("Mark on")));
break;
case LFUN_MARK_TOGGLE:
cur.clearSelection();
if (cur.mark()) {
cur.mark() = false;
cur.message(N_("Mark removed"));
cur.message(lyx::from_utf8(N_("Mark removed")));
} else {
cur.mark() = true;
cur.message(N_("Mark set"));
cur.message(lyx::from_utf8(N_("Mark set")));
}
cur.resetAnchor();
break;
@ -1179,23 +1179,23 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
to = doc_iterator_end(buffer_->inset());
}
int const count = countWords(from, to);
string message;
docstring message;
if (count != 1) {
if (cur.selection())
message = bformat(lyx::to_utf8(_("%1$d words in selection.")),
message = bformat(_("%1$d words in selection."),
count);
else
message = bformat(lyx::to_utf8(_("%1$d words in document.")),
message = bformat(_("%1$d words in document."),
count);
}
else {
if (cur.selection())
message = lyx::to_utf8(_("One word in selection."));
message = _("One word in selection.");
else
message = lyx::to_utf8(_("One word in document."));
message = _("One word in document.");
}
Alert::information(lyx::to_utf8(_("Count words")), message);
Alert::information(_("Count words"), message);
}
break;

View File

@ -402,12 +402,13 @@ void switchBetweenClasses(textclass_type c1, textclass_type c2,
it->layout(tclass2.defaultLayout());
if (!hasLayout && name != tclass1.defaultLayoutName()) {
string const s = bformat(
lyx::to_utf8(_("Layout had to be changed from\n%1$s to %2$s\n"
"because of class conversion from\n%3$s to %4$s")),
name, it->layout()->name(), tclass1.name(), tclass2.name());
docstring const s = bformat(
_("Layout had to be changed from\n%1$s to %2$s\n"
"because of class conversion from\n%3$s to %4$s"),
lyx::from_utf8(name), lyx::from_utf8(it->layout()->name()),
lyx::from_utf8(tclass1.name()), lyx::from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(lyx::to_utf8(_("Changed Layout")), s,
errorlist.push_back(ErrorItem(_("Changed Layout"), s,
it->id(), 0,
it->size()));
}
@ -425,16 +426,16 @@ void switchBetweenClasses(textclass_type c1, textclass_type c2,
if (found_cs == tclass2.charstyles().end()) {
// The character style is undefined in tclass2
inset.setUndefined();
string const s = bformat(lyx::to_utf8(_(
docstring const s = bformat(_(
"Character style %1$s is "
"undefined because of class "
"conversion from\n%2$s to %3$s")),
name, tclass1.name(), tclass2.name());
"conversion from\n%2$s to %3$s"),
lyx::from_utf8(name), lyx::from_utf8(tclass1.name()),
lyx::from_utf8(tclass2.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(
lyx::to_utf8(_("Undefined character style")),
s, it.paragraph().id(),
it.pos(), it.pos() + 1));
_("Undefined character style"),
s, it.paragraph().id(), it.pos(), it.pos() + 1));
} else if (inset.undefined()) {
// The character style is undefined in
// tclass1 and is defined in tclass2

View File

@ -12,7 +12,7 @@
#include "FuncStatus.h"
using std::string;
using lyx::docstring;
FuncStatus::FuncStatus() : v_(OK)
{
@ -80,13 +80,13 @@ bool FuncStatus::onoff(bool b) const
}
void FuncStatus::message(string const & m)
void FuncStatus::message(docstring const & m)
{
message_ = m;
}
string const & FuncStatus::message() const
docstring const & FuncStatus::message() const
{
return message_;
}

View File

@ -12,7 +12,7 @@
#ifndef FUNC_STATUS_H
#define FUNC_STATUS_H
#include <string>
#include "support/docstring.h"
/// The status of a function.
@ -41,7 +41,7 @@ private:
unsigned int v_;
std::string message_;
lyx::docstring message_;
public:
///
@ -67,9 +67,9 @@ public:
bool onoff(bool b) const;
///
void message(std::string const & m);
void message(lyx::docstring const & m);
///
std::string const & message() const;
lyx::docstring const & message() const;
};
#endif

View File

@ -49,6 +49,8 @@ using lyx::support::Systemcall;
using lyx::support::unlink;
using lyx::support::trim;
using lyx::docstring;
namespace os = lyx::support::os;
namespace fs = boost::filesystem;
@ -82,9 +84,9 @@ extern BufferList bufferlist;
namespace {
string runMessage(unsigned int count)
docstring runMessage(unsigned int count)
{
return bformat(lyx::to_utf8(_("Waiting for LaTeX run number %1$d")), count);
return bformat(_("Waiting for LaTeX run number %1$d"), count);
}
} // anon namespace
@ -278,7 +280,7 @@ int LaTeX::run(TeXErrors & terr)
if (head.haschanged(onlyFilename(changeExtension(file, ".idx")))) {
// no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
message(lyx::to_utf8(_("Running MakeIndex.")));
message(_("Running MakeIndex."));
rerun |= runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams);
}
@ -290,7 +292,7 @@ int LaTeX::run(TeXErrors & terr)
// tags is found -> run bibtex and set rerun = true;
// no checks for now
lyxerr[Debug::LATEX] << "Running BibTeX." << endl;
message(lyx::to_utf8(_("Running BibTeX.")));
message(_("Running BibTeX."));
updateBibtexDependencies(head, bibtex_info);
rerun |= runBibTeX(bibtex_info);
} else if (!had_depfile) {
@ -346,7 +348,7 @@ int LaTeX::run(TeXErrors & terr)
if (head.haschanged(onlyFilename(changeExtension(file, ".idx")))) {
// no checks for now
lyxerr[Debug::LATEX] << "Running MakeIndex." << endl;
message(lyx::to_utf8(_("Running MakeIndex.")));
message(_("Running MakeIndex."));
rerun = runMakeIndex(onlyFilename(changeExtension(file, ".idx")), runparams);
}

View File

@ -126,7 +126,7 @@ public:
};
/// This signal emits an informative message
boost::signal<void(std::string)> message;
boost::signal<void(lyx::docstring)> message;
/**

View File

@ -438,7 +438,7 @@ void expandLastfiles(Menu & tomenu, LyXView const * view)
for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) {
docstring const label = convert<docstring>(ii) + lyx::from_ascii(". ")
+ lyx::from_utf8(makeDisplayPath((*lfit), 30))
+ makeDisplayPath((*lfit), 30)
+ char_type('|') + convert<docstring>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_FILE_OPEN, (*lfit))), view);
}
@ -460,7 +460,7 @@ void expandDocuments(Menu & tomenu, LyXView const * view)
Strings::const_iterator docit = names.begin();
Strings::const_iterator end = names.end();
for (; docit != end; ++docit, ++ii) {
docstring label = lyx::from_utf8(makeDisplayPath(*docit, 20));
docstring label = makeDisplayPath(*docit, 20);
if (ii < 10)
label = convert<docstring>(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert<docstring>(ii);
tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit)), view);

View File

@ -14,6 +14,8 @@
#include "SpellBase.h"
#include "gettext.h"
using lyx::docstring;
using std::string;
@ -43,7 +45,7 @@ string const SpellBase::nextMiss()
}
string const SpellBase::error()
docstring const SpellBase::error()
{
return lyx::to_utf8(_("Native OS API not yet supported."));
return _("Native OS API not yet supported.");
}

View File

@ -13,6 +13,8 @@
#ifndef SPELL_BASE_H
#define SPELL_BASE_H
#include "support/docstring.h"
#include <string>
class BufferParams;
@ -59,7 +61,7 @@ public:
virtual std::string const nextMiss();
/// give an error message on messy exit
virtual std::string const error();
virtual lyx::docstring const error();
};
#endif // SPELL_BASE_H

View File

@ -20,6 +20,8 @@
#include <boost/assert.hpp>
using lyx::docstring;
using std::string;
@ -132,13 +134,13 @@ string const ASpell::nextMiss()
}
string const ASpell::error()
docstring const ASpell::error()
{
char const * err = 0;
if (spell_error_object && aspell_error_number(spell_error_object) != 0) {
err = aspell_error_message(spell_error_object);
}
return (err ? err : "");
return (err ? lyx::from_utf8(err) : docstring());
}

View File

@ -53,7 +53,7 @@ public:
virtual std::string const nextMiss();
/// give an error message on messy exit
virtual std::string const error();
virtual lyx::docstring const error();
private:
/// add a speller of the given language

View File

@ -231,8 +231,9 @@ Buffer::~Buffer()
closing();
if (!temppath().empty() && !destroyDir(temppath())) {
Alert::warning(lyx::to_utf8(_("Could not remove temporary directory")),
bformat(lyx::to_utf8(_("Could not remove the temporary directory %1$s")), temppath()));
Alert::warning(_("Could not remove temporary directory"),
bformat(_("Could not remove the temporary directory %1$s"),
lyx::from_utf8(temppath())));
}
// Remove any previewed LaTeX snippets associated with this buffer.
@ -389,9 +390,9 @@ namespace {
void unknownClass(string const & unknown)
{
Alert::warning(lyx::to_utf8(_("Unknown document class")),
bformat(lyx::to_utf8(_("Using the default document class, because the "
"class %1$s is unknown.")), unknown));
Alert::warning(_("Unknown document class"),
bformat(_("Using the default document class, because the "
"class %1$s is unknown."), lyx::from_utf8(unknown)));
}
} // anon
@ -445,18 +446,18 @@ int Buffer::readHeader(LyXLex & lex)
unknownClass(unknown);
} else {
++unknown_tokens;
string const s = bformat(lyx::to_utf8(_("Unknown token: "
"%1$s %2$s\n")),
token,
lex.getString());
errorList.push_back(ErrorItem(lyx::to_utf8(_("Document header error")),
docstring const s = bformat(_("Unknown token: "
"%1$s %2$s\n"),
lyx::from_utf8(token),
lyx::from_utf8(lex.getString()));
errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
}
}
if (begin_header_line) {
string const s = lyx::to_utf8(_("\\begin_header is missing"));
errorList.push_back(ErrorItem(lyx::to_utf8(_("Document header error")),
docstring const s = _("\\begin_header is missing");
errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
@ -475,8 +476,8 @@ bool Buffer::readDocument(LyXLex & lex)
lex.next();
string const token = lex.getString();
if (token != "\\begin_document") {
string const s = lyx::to_utf8(_("\\begin_document is missing"));
errorList.push_back(ErrorItem(lyx::to_utf8(_("Document header error")),
docstring const s = _("\\begin_document is missing");
errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
@ -486,9 +487,9 @@ bool Buffer::readDocument(LyXLex & lex)
readHeader(lex);
if (!params().getLyXTextClass().load(filePath())) {
string theclass = params().getLyXTextClass().name();
Alert::error(lyx::to_utf8(_("Can't load document class")), bformat(
"Using the default document class, because the "
" class %1$s could not be loaded.", theclass));
Alert::error(_("Can't load document class"), bformat(
_("Using the default document class, because the "
" class %1$s could not be loaded."), lyx::from_utf8(theclass)));
params().textclass = 0;
}
@ -599,8 +600,8 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
BOOST_ASSERT(!filename.empty());
if (!lex.isOK()) {
Alert::error(lyx::to_utf8(_("Document could not be read")),
bformat(lyx::to_utf8(_("%1$s could not be read.")), filename));
Alert::error(_("Document could not be read"),
bformat(_("%1$s could not be read."), lyx::from_utf8(filename)));
return false;
}
@ -608,8 +609,8 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
string const token(lex.getString());
if (!lex.isOK()) {
Alert::error(lyx::to_utf8(_("Document could not be read")),
bformat(lyx::to_utf8(_("%1$s could not be read.")), filename));
Alert::error(_("Document could not be read"),
bformat(_("%1$s could not be read."), lyx::from_utf8(filename)));
return false;
}
@ -617,9 +618,9 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
if (token != "\\lyxformat") {
lyxerr << "Token: " << token << endl;
Alert::error(lyx::to_utf8(_("Document format failure")),
bformat(lyx::to_utf8(_("%1$s is not a LyX document.")),
filename));
Alert::error(_("Document format failure"),
bformat(_("%1$s is not a LyX document."),
lyx::from_utf8(filename)));
return false;
}
@ -637,22 +638,22 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
if (file_format != LYX_FORMAT) {
string const tmpfile = tempName();
if (tmpfile.empty()) {
Alert::error(lyx::to_utf8(_("Conversion failed")),
bformat(lyx::to_utf8(_("%1$s is from an earlier"
Alert::error(_("Conversion failed"),
bformat(_("%1$s is from an earlier"
" version of LyX, but a temporary"
" file for converting it could"
" not be created.")),
filename));
" not be created."),
lyx::from_utf8(filename)));
return false;
}
string const lyx2lyx = libFileSearch("lyx2lyx", "lyx2lyx");
if (lyx2lyx.empty()) {
Alert::error(lyx::to_utf8(_("Conversion script not found")),
bformat(lyx::to_utf8(_("%1$s is from an earlier"
Alert::error(_("Conversion script not found"),
bformat(_("%1$s is from an earlier"
" version of LyX, but the"
" conversion script lyx2lyx"
" could not be found.")),
filename));
" could not be found."),
lyx::from_utf8(filename)));
return false;
}
ostringstream command;
@ -668,11 +669,11 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
cmd_ret const ret = runCommand(command_str);
if (ret.first != 0) {
Alert::error(lyx::to_utf8(_("Conversion script failed")),
bformat(lyx::to_utf8(_("%1$s is from an earlier version"
Alert::error(_("Conversion script failed"),
bformat(_("%1$s is from an earlier version"
" of LyX, but the lyx2lyx script"
" failed to convert it.")),
filename));
" failed to convert it."),
lyx::from_utf8(filename)));
return false;
} else {
bool const ret = readFile(tmpfile);
@ -683,10 +684,10 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
}
if (readDocument(lex)) {
Alert::error(lyx::to_utf8(_("Document format failure")),
bformat(lyx::to_utf8(_("%1$s ended unexpectedly, which means"
" that it is probably corrupted.")),
filename));
Alert::error(_("Document format failure"),
bformat(_("%1$s ended unexpectedly, which means"
" that it is probably corrupted."),
lyx::from_utf8(filename)));
}
//lyxerr << "removing " << MacroTable::localMacros().size()
@ -720,10 +721,10 @@ bool Buffer::save() const
fs::copy_file(fileName(), s, false);
}
catch (fs::filesystem_error const & fe) {
Alert::error(lyx::to_utf8(_("Backup failure")),
bformat(lyx::to_utf8(_("LyX was not able to make a backup copy in %1$s.\n"
"Please check if the directory exists and is writeable.")),
fs::path(s).branch_path().native_directory_string()));
Alert::error(_("Backup failure"),
bformat(_("LyX was not able to make a backup copy in %1$s.\n"
"Please check if the directory exists and is writeable."),
lyx::from_utf8(fs::path(s).branch_path().native_directory_string())));
lyxerr[Debug::DEBUG] << "Fs error: "
<< fe.what() << endl;
}
@ -1076,7 +1077,7 @@ int Buffer::runChktex()
string const org_path = filePath();
Path p(path); // path to LaTeX file
message(lyx::to_utf8(_("Running chktex...")));
message(_("Running chktex..."));
// Generate the LaTeX file if neccessary
OutputParams runparams;
@ -1089,8 +1090,8 @@ int Buffer::runChktex()
int const res = chktex.run(terr); // run chktex
if (res == -1) {
Alert::error(lyx::to_utf8(_("chktex failure")),
lyx::to_utf8(_("Could not run chktex successfully.")));
Alert::error(_("chktex failure"),
_("Could not run chktex successfully."));
} else if (res > 0) {
// Fill-in the error list with the TeX errors
bufferErrors(*this, terr, errorLists_["ChkTex"]);

View File

@ -117,7 +117,7 @@ public:
/// This signal is emitted when some parsing error shows up.
boost::signal<void(std::string)> errors;
/// This signal is emitted when some message shows up.
boost::signal<void(std::string)> message;
boost::signal<void(lyx::docstring)> message;
/// This signal is emitted when the buffer busy status change.
boost::signal<void(bool)> busy;
/// This signal is emitted when the buffer readonly status change.

View File

@ -51,6 +51,7 @@
using namespace std;
using lyx::pit_type;
using lyx::docstring;
using lyx::support::bformat;
using lyx::support::libFileSearch;
using lyx::support::makeDisplayPath;
@ -73,10 +74,10 @@ bool readFile(Buffer * const b, string const & s)
// File information about normal file
if (!fs::exists(s)) {
string const file = makeDisplayPath(s, 50);
string text = bformat(lyx::to_utf8(_("The specified document\n%1$s"
"\ncould not be read.")), file);
Alert::error(lyx::to_utf8(_("Could not read document")), text);
docstring const file = makeDisplayPath(s, 50);
docstring text = bformat(_("The specified document\n%1$s"
"\ncould not be read."), file);
Alert::error(_("Could not read document"), text);
return false;
}
@ -86,14 +87,14 @@ bool readFile(Buffer * const b, string const & s)
if (fs::exists(e) && fs::exists(s)
&& fs::last_write_time(e) > fs::last_write_time(s))
{
string const file = makeDisplayPath(s, 20);
string const text =
bformat(lyx::to_utf8(_("An emergency save of the document "
docstring const file = makeDisplayPath(s, 20);
docstring const text =
bformat(_("An emergency save of the document "
"%1$s exists.\n\n"
"Recover emergency save?")), file);
switch (Alert::prompt(lyx::to_utf8(_("Load emergency save?")), text, 0, 2,
lyx::to_utf8(_("&Recover")), lyx::to_utf8(_("&Load Original")),
lyx::to_utf8(_("&Cancel"))))
"Recover emergency save?"), file);
switch (Alert::prompt(_("Load emergency save?"), text, 0, 2,
_("&Recover"), _("&Load Original"),
_("&Cancel")))
{
case 0:
// the file is not saved if we load the emergency file.
@ -112,14 +113,14 @@ bool readFile(Buffer * const b, string const & s)
if (fs::exists(a) && fs::exists(s)
&& fs::last_write_time(a) > fs::last_write_time(s))
{
string const file = makeDisplayPath(s, 20);
string const text =
bformat(lyx::to_utf8(_("The backup of the document "
docstring const file = makeDisplayPath(s, 20);
docstring const text =
bformat(_("The backup of the document "
"%1$s is newer.\n\nLoad the "
"backup instead?")), file);
switch (Alert::prompt(lyx::to_utf8(_("Load backup?")), text, 0, 2,
lyx::to_utf8(_("&Load backup")), lyx::to_utf8(_("Load &original")),
lyx::to_utf8(_("&Cancel") )))
"backup instead?"), file);
switch (Alert::prompt(_("Load backup?"), text, 0, 2,
_("&Load backup"), _("Load &original"),
_("&Cancel") ))
{
case 0:
// the file is not saved if we load the autosave file.
@ -153,14 +154,14 @@ bool loadLyXFile(Buffer * b, string const & s)
return true;
}
} else {
string const file = makeDisplayPath(s, 20);
docstring const file = makeDisplayPath(s, 20);
// Here we probably should run
if (LyXVC::file_not_found_hook(s)) {
string const text =
bformat(lyx::to_utf8(_("Do you want to retrieve the document"
" %1$s from version control?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Retrieve from version control?")),
text, 0, 1, lyx::to_utf8(_("&Retrieve")), lyx::to_utf8(_("&Cancel")));
docstring const text =
bformat(_("Do you want to retrieve the document"
" %1$s from version control?"), file);
int const ret = Alert::prompt(_("Retrieve from version control?"),
text, 0, 1, _("&Retrieve"), _("&Cancel"));
if (ret == 0) {
// How can we know _how_ to do the checkout?
@ -191,9 +192,11 @@ Buffer * newFile(string const & filename, string const & templatename,
if (!tname.empty()) {
if (!b->readFile(tname)) {
string const file = makeDisplayPath(tname, 50);
string const text = bformat(lyx::to_utf8(_("The specified document template\n%1$s\ncould not be read.")), file);
Alert::error(lyx::to_utf8(_("Could not read template")), text);
docstring const file = makeDisplayPath(tname, 50);
docstring const text = bformat(
_("The specified document template\n%1$s\ncould not be read."),
file);
Alert::error(_("Could not read template"), text);
bufferlist.release(b);
return 0;
}
@ -232,8 +235,8 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr,
pos_end);
} while (found && id_start == id_end && pos_start == pos_end);
errorList.push_back(ErrorItem(cit->error_desc,
cit->error_text, id_start, pos_start, pos_end));
errorList.push_back(ErrorItem(lyx::from_utf8(cit->error_desc),
lyx::from_utf8(cit->error_text), id_start, pos_start, pos_end));
}
}
@ -483,7 +486,7 @@ void setLabel(Buffer const & buf, ParIterator & it)
}
}
string s;
docstring s;
if (!type.empty()) {
Floating const & fl = textclass.floats().getType(type);
@ -491,14 +494,14 @@ void setLabel(Buffer const & buf, ParIterator & it)
// Doesn't work... yet.
// FIXME UNICODE
s = bformat(lyx::to_utf8(_("%1$s #:")), lyx::to_utf8(buf.B_(fl.name())));
s = bformat(_("%1$s #:"), buf.B_(fl.name()));
} else {
// par->SetLayout(0);
// FIXME UNICODE
s = lyx::to_utf8(buf.B_(layout->labelstring()));
s = buf.B_(layout->labelstring());
}
par.params().labelString(s);
par.params().labelString(lyx::to_utf8(s));
} else if (layout->labeltype == LABEL_NO_LABEL)
par.params().labelString(string());
else

View File

@ -34,6 +34,7 @@
#include <algorithm>
#include <functional>
using lyx::docstring;
using lyx::support::addName;
using lyx::support::bformat;
using lyx::support::makeAbsPath;
@ -71,17 +72,18 @@ bool BufferList::quitWriteBuffer(Buffer * buf)
{
BOOST_ASSERT(buf);
string file;
docstring file;
if (buf->isUnnamed())
file = onlyFilename(buf->fileName());
file = lyx::from_utf8(onlyFilename(buf->fileName()));
else
file = makeDisplayPath(buf->fileName(), 30);
string const text =
bformat(lyx::to_utf8(_("The document %1$s has unsaved changes.\n\n"
"Do you want to save the document or discard the changes?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Save changed document?")),
text, 0, 2, lyx::to_utf8(_("&Save")), lyx::to_utf8(_("&Discard")), lyx::to_utf8(_("&Cancel")));
docstring const text =
bformat(_("The document %1$s has unsaved changes.\n\n"
"Do you want to save the document or discard the changes?"),
file);
int const ret = Alert::prompt(_("Save changed document?"),
text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
if (ret == 0) {
// FIXME: WriteAs can be asynch !
@ -178,17 +180,18 @@ bool BufferList::close(Buffer * buf, bool const ask)
return true;
}
string fname;
docstring fname;
if (buf->isUnnamed())
fname = onlyFilename(buf->fileName());
fname = lyx::from_utf8(onlyFilename(buf->fileName()));
else
fname = makeDisplayPath(buf->fileName(), 30);
string const text =
bformat(lyx::to_utf8(_("The document %1$s has unsaved changes.\n\n"
"Do you want to save the document or discard the changes?")), fname);
int const ret = Alert::prompt(lyx::to_utf8(_("Save changed document?")),
text, 0, 2, lyx::to_utf8(_("&Save")), lyx::to_utf8(_("&Discard")), lyx::to_utf8(_("&Cancel")));
docstring const text =
bformat(_("The document %1$s has unsaved changes.\n\n"
"Do you want to save the document or discard the changes?"),
fname);
int const ret = Alert::prompt(_("Save changed document?"),
text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
if (ret == 0) {
if (buf->isUnnamed()) {
@ -307,7 +310,9 @@ void BufferList::emergencyWrite(Buffer * buf)
string const doc = buf->isUnnamed()
? onlyFilename(buf->fileName()) : buf->fileName();
lyxerr << bformat(lyx::to_utf8(_("LyX: Attempting to save document %1$s")), doc) << endl;
lyxerr << lyx::to_utf8(
bformat(_("LyX: Attempting to save document %1$s"), lyx::from_utf8(doc)))
<< endl;
// We try to save three places:
// 1) Same place as document. Unless it is an unnamed doc.

View File

@ -47,6 +47,8 @@
#include <sstream>
namespace support = lyx::support;
using lyx::docstring;
using lyx::support::bformat;
using lyx::support::rtrim;
using lyx::support::tokenPos;
@ -427,11 +429,11 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
// fail because of the lack of path info. Warnings will be given although
// the layout file will be correctly loaded later.
if (!getLyXTextClass().isTeXClassAvailable()) {
string const msg =
bformat(lyx::to_utf8(_("The document uses a missing "
"TeX class \"%1$s\".\n")), classname);
Alert::warning(lyx::to_utf8(_("Document class not available")),
msg + lyx::to_utf8(_("LyX will not be able to produce output.")));
docstring const msg =
bformat(_("The document uses a missing "
"TeX class \"%1$s\".\n"), lyx::from_utf8(classname));
Alert::warning(_("Document class not available"),
msg + _("LyX will not be able to produce output."));
}
} else if (token == "\\begin_preamble") {
readPreamble(lex);

View File

@ -300,7 +300,7 @@ void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes,
{
LCursor tmpcur = bv->cursor();
if (!findInset(tmpcur, codes, same_content)) {
bv->cursor().message(lyx::to_utf8(_("No more insets")));
bv->cursor().message(_("No more insets"));
return;
}

View File

@ -86,7 +86,7 @@ void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level)
// avoid _(...) re-entrance problem
string const s = _(errorTags[i].desc);
os << bformat(_("Debugging `%1$s' (%2$s)"),
errorTags[i].name, s)
lyx::from_utf8(errorTags[i].name), lyx::from_utf8(s))
<< '\n';
}
}

View File

@ -50,6 +50,8 @@ using lyx::support::split;
using lyx::support::subst;
using lyx::support::Systemcall;
using lyx::docstring;
using std::endl;
using std::find_if;
using std::string;
@ -315,11 +317,11 @@ bool Converters::convert(Buffer const * buffer,
return true;
}
}
Alert::error(lyx::to_utf8(_("Cannot convert file")),
bformat(lyx::to_utf8(_("No information for converting %1$s "
Alert::error(_("Cannot convert file"),
bformat(_("No information for converting %1$s "
"format files to %2$s.\n"
"Define a convertor in the preferences.")),
from_format, to_format));
"Define a convertor in the preferences."),
lyx::from_ascii(from_format), lyx::from_ascii(to_format)));
return false;
}
OutputParams runparams;
@ -395,8 +397,8 @@ bool Converters::convert(Buffer const * buffer,
lyxerr[Debug::FILES] << "Calling " << command << endl;
if (buffer)
buffer->message(lyx::to_utf8(_("Executing command: "))
+ command);
buffer->message(_("Executing command: ")
+ lyx::from_utf8(command));
Systemcall::Starttype const type = (dummy)
? Systemcall::DontWait : Systemcall::Wait;
@ -435,14 +437,14 @@ bool Converters::convert(Buffer const * buffer,
if (res) {
if (conv.to == "program") {
Alert::error(lyx::to_utf8(_("Build errors")),
lyx::to_utf8(_("There were errors during the build process.")));
Alert::error(_("Build errors"),
_("There were errors during the build process."));
} else {
// FIXME: this should go out of here. For example, here we cannot say if
// it is a document (.lyx) or something else. Same goes for elsewhere.
Alert::error(lyx::to_utf8(_("Cannot convert file")),
bformat(lyx::to_utf8(_("An error occurred whilst running %1$s")),
command.substr(0, 50)));
Alert::error(_("Cannot convert file"),
bformat(_("An error occurred whilst running %1$s"),
lyx::from_ascii(command.substr(0, 50))));
}
return false;
}
@ -464,9 +466,9 @@ bool Converters::convert(Buffer const * buffer,
token_base, to_base);
Mover const & mover = movers(conv.from);
if (!mover.rename(from, to)) {
Alert::error(lyx::to_utf8(_("Cannot convert file")),
bformat(lyx::to_utf8(_("Could not move a temporary file from %1$s to %2$s.")),
from, to));
Alert::error(_("Cannot convert file"),
bformat(_("Could not move a temporary file from %1$s to %2$s."),
lyx::from_ascii(from), lyx::from_ascii(to)));
return false;
}
}
@ -503,11 +505,11 @@ bool Converters::move(string const & fmt,
? mover.copy(from2, to2)
: mover.rename(from2, to2);
if (!moved && no_errors) {
Alert::error(lyx::to_utf8(_("Cannot convert file")),
Alert::error(_("Cannot convert file"),
bformat(copy ?
lyx::to_utf8(_("Could not copy a temporary file from %1$s to %2$s.")) :
lyx::to_utf8(_("Could not move a temporary file from %1$s to %2$s.")),
from2, to2));
_("Could not copy a temporary file from %1$s to %2$s.") :
_("Could not move a temporary file from %1$s to %2$s."),
lyx::from_ascii(from2), lyx::from_ascii(to2)));
no_errors = false;
}
}
@ -556,10 +558,10 @@ bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
namespace {
class showMessage : public std::unary_function<string, void>, public boost::signals::trackable {
class showMessage : public std::unary_function<docstring, void>, public boost::signals::trackable {
public:
showMessage(Buffer const & b) : buffer_(b) {};
void operator()(string const & m) const
void operator()(docstring const & m) const
{
buffer_.message(m);
}
@ -574,7 +576,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
OutputParams const & runparams, ErrorList & errorList)
{
buffer.busy(true);
buffer.message(lyx::to_utf8(_("Running LaTeX...")));
buffer.message(_("Running LaTeX..."));
runparams.document_language = buffer.params().language->babel();
@ -591,14 +593,14 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
// check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) {
string const str =
bformat(lyx::to_utf8(_("LaTeX did not run successfully. "
docstring const str =
bformat(_("LaTeX did not run successfully. "
"Additionally, LyX could not locate "
"the LaTeX log %1$s.")), name);
Alert::error(lyx::to_utf8(_("LaTeX failed")), str);
"the LaTeX log %1$s."), lyx::from_utf8(name));
Alert::error(_("LaTeX failed"), str);
} else if (result & LaTeX::NO_OUTPUT) {
Alert::warning(lyx::to_utf8(_("Output is empty")),
lyx::to_utf8(_("An empty output file was generated.")));
Alert::warning(_("Output is empty"),
_("An empty output file was generated."));
}

View File

@ -1103,13 +1103,13 @@ void LCursor::handleFont(string const & font)
}
void LCursor::message(string const & msg) const
void LCursor::message(docstring const & msg) const
{
bv().owner()->getLyXFunc().setMessage(msg);
}
void LCursor::errorMessage(string const & msg) const
void LCursor::errorMessage(docstring const & msg) const
{
bv().owner()->getLyXFunc().setErrorMessage(msg);
}

View File

@ -283,9 +283,9 @@ public:
void handleFont(std::string const & font);
/// display a message
void message(std::string const & msg) const;
void message(lyx::docstring const & msg) const;
/// display an error message
void errorMessage(std::string const & msg) const;
void errorMessage(lyx::docstring const & msg) const;
///
std::string getPossibleLabel();

View File

@ -20,6 +20,7 @@
#include <iostream>
#include <iomanip>
using lyx::docstring;
using lyx::support::ascii_lowercase;
using lyx::support::bformat;
using lyx::support::isStrInt;
@ -108,9 +109,9 @@ void lyx_debug_trait::showLevel(ostream & os, lyx_debug_trait::type level)
&& errorTags[i].level != Debug::NONE
&& errorTags[i].level & level) {
// avoid lyx::to_utf8(_(...)) re-entrance problem
string const s = lyx::to_utf8(_(errorTags[i].desc));
os << bformat(lyx::to_utf8(_("Debugging `%1$s' (%2$s)")),
errorTags[i].name, s)
docstring const s = _(errorTags[i].desc);
os << lyx::to_utf8(bformat(_("Debugging `%1$s' (%2$s)"),
lyx::from_utf8(errorTags[i].name), s))
<< '\n';
}
}
@ -127,4 +128,5 @@ void lyx_debug_trait::showTags(ostream & os)
os.flush();
}
LyXErr lyxerr;

View File

@ -14,6 +14,7 @@
#define LYXDEBUG_H
#include "support/debugstream.h"
#include "support/docstring.h"
/** Ideally this should have been a namespace, but since we try to be
* compilable on older C++ compilators too, we use a struct instead.

View File

@ -12,11 +12,13 @@
#include "errorlist.h"
using lyx::docstring;
using lyx::pos_type;
using std::string;
ErrorItem::ErrorItem(string const & error_, string const & description_,
ErrorItem::ErrorItem(docstring const & error_, docstring const & description_,
int par_id_, pos_type pos_start_, pos_type pos_end_)
: error(error_), description(description_), par_id(par_id_),
pos_start(pos_start_), pos_end(pos_end_)

View File

@ -22,12 +22,12 @@ class Buffer;
/// A class to hold an error item
class ErrorItem {
public:
std::string error;
std::string description;
lyx::docstring error;
lyx::docstring description;
int par_id;
lyx::pos_type pos_start;
lyx::pos_type pos_end;
ErrorItem(std::string const & error, std::string const & description,
ErrorItem(lyx::docstring const & error, lyx::docstring const & description,
int parid, lyx::pos_type posstart, lyx::pos_type posend);
ErrorItem();
};

View File

@ -47,6 +47,8 @@ using lyx::support::onlyPath;
using lyx::support::package;
using lyx::support::prefixIs;
using lyx::docstring;
using std::find;
using std::string;
using std::vector;
@ -74,13 +76,13 @@ vector<string> const Backends(Buffer const & buffer)
int checkOverwrite(string const & filename)
{
if (fs::exists(filename)) {
string text = bformat(lyx::to_utf8(_("The file %1$s already exists.\n\n"
"Do you want to over-write that file?")),
docstring text = bformat(_("The file %1$s already exists.\n\n"
"Do you want to over-write that file?"),
makeDisplayPath(filename));
return Alert::prompt(lyx::to_utf8(_("Over-write file?")),
return Alert::prompt(_("Over-write file?"),
text, 0, 2,
lyx::to_utf8(_("&Over-write")), lyx::to_utf8(_("Over-write &all")),
lyx::to_utf8(_("&Cancel export")));
_("&Over-write"), _("Over-write &all"),
_("&Cancel export"));
}
return 0;
}
@ -129,8 +131,8 @@ CopyStatus copyFile(string const & format,
Mover const & mover = movers(format);
if (!mover.copy(sourceFile, destFile, latexFile))
Alert::error(lyx::to_utf8(_("Couldn't copy file")),
bformat(lyx::to_utf8(_("Copying %1$s to %2$s failed.")),
Alert::error(_("Couldn't copy file"),
bformat(_("Copying %1$s to %2$s failed."),
makeDisplayPath(sourceFile),
makeDisplayPath(destFile)));
@ -168,8 +170,8 @@ bool Exporter::Export(Buffer * buffer, string const & format,
}
}
if (backend_format.empty()) {
Alert::error(lyx::to_utf8(_("Couldn't export file")),
bformat(lyx::to_utf8(_("No information for exporting the format %1$s.")),
Alert::error(_("Couldn't export file"),
bformat(_("No information for exporting the format %1$s."),
formats.prettyName(format)));
return false;
}
@ -202,8 +204,8 @@ bool Exporter::Export(Buffer * buffer, string const & format,
buffer->makeLaTeXFile(filename, string(), runparams);
} else if (!lyxrc.tex_allows_spaces
&& contains(buffer->filePath(), ' ')) {
Alert::error(lyx::to_utf8(_("File name error")),
lyx::to_utf8(_("The directory path to the document cannot contain spaces.")));
Alert::error(_("File name error"),
_("The directory path to the document cannot contain spaces."));
return false;
} else {
runparams.nice = false;
@ -238,19 +240,19 @@ bool Exporter::Export(Buffer * buffer, string const & format,
it->exportName, status == FORCE);
}
if (status == CANCEL) {
buffer->message(lyx::to_utf8(_("Document export cancelled.")));
buffer->message(_("Document export cancelled."));
} else if (fs::exists(tmp_result_file)) {
// Finally copy the main file
status = copyFile(format, tmp_result_file,
result_file, result_file,
status == FORCE);
buffer->message(bformat(lyx::to_utf8(_("Document exported as %1$s "
"to file `%2$s'")),
buffer->message(bformat(_("Document exported as %1$s "
"to file `%2$s'"),
formats.prettyName(format),
makeDisplayPath(result_file)));
} else {
// This must be a dummy converter like fax (bug 1888)
buffer->message(bformat(lyx::to_utf8(_("Document exported as %1$s")),
buffer->message(bformat(_("Document exported as %1$s"),
formats.prettyName(format)));
}
}

View File

@ -27,6 +27,7 @@
#include <boost/filesystem/operations.hpp>
using lyx::docstring;
using lyx::support::absolutePath;
using lyx::support::bformat;
using lyx::support::compare_ascii_no_case;
@ -262,9 +263,9 @@ bool Formats::view(Buffer const & buffer, string const & filename,
{
BOOST_ASSERT(absolutePath(filename));
if (filename.empty() || !fs::exists(filename)) {
Alert::error(lyx::to_utf8(_("Cannot view file")),
bformat(lyx::to_utf8(_("File does not exist: %1$s")),
filename));
Alert::error(_("Cannot view file"),
bformat(_("File does not exist: %1$s"),
lyx::from_utf8(filename)));
return false;
}
@ -275,8 +276,8 @@ bool Formats::view(Buffer const & buffer, string const & filename,
if (!format || format->viewer().empty()) {
// FIXME: I believe this is the wrong place to show alerts, it should be done
// by the caller (this should be "utility" code)
Alert::error(lyx::to_utf8(_("Cannot view file")),
bformat(lyx::to_utf8(_("No information for viewing %1$s")),
Alert::error(_("Cannot view file"),
bformat(_("No information for viewing %1$s"),
prettyName(format_name)));
return false;
}
@ -285,9 +286,9 @@ bool Formats::view(Buffer const & buffer, string const & filename,
if (os::autoOpenFile(filename, os::VIEW))
return true;
else {
Alert::error(lyx::to_utf8(_("Cannot view file")),
bformat(lyx::to_utf8(_("Auto-view file %1$s failed")),
filename));
Alert::error(_("Cannot view file"),
bformat(_("Auto-view file %1$s failed"),
lyx::from_utf8(filename)));
return false;
}
}
@ -312,14 +313,14 @@ bool Formats::view(Buffer const & buffer, string const & filename,
command = subst(command, token_path, quoteName(onlyPath(filename)));
command = subst(command, token_socket, quoteName(lyxsocket->address()));
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
buffer.message(lyx::to_utf8(_("Executing command: ")) + command);
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
Systemcall one;
int const res = one.startscript(Systemcall::DontWait, command);
if (res) {
Alert::error(lyx::to_utf8(_("Cannot view file")),
bformat(lyx::to_utf8(_("An error occurred whilst running %1$s")),
Alert::error(_("Cannot view file"),
bformat(_("An error occurred whilst running %1$s"),
makeDisplayPath(command, 50)));
return false;
}
@ -332,9 +333,9 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
{
BOOST_ASSERT(absolutePath(filename));
if (filename.empty() || !fs::exists(filename)) {
Alert::error(lyx::to_utf8(_("Cannot edit file")),
bformat(lyx::to_utf8(_("File does not exist: %1$s")),
filename));
Alert::error(_("Cannot edit file"),
bformat(_("File does not exist: %1$s"),
lyx::from_utf8(filename)));
return false;
}
@ -345,8 +346,8 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
if (!format || format->editor().empty()) {
// FIXME: I believe this is the wrong place to show alerts, it should
// be done by the caller (this should be "utility" code)
Alert::error(lyx::to_utf8(_("Cannot edit file")),
bformat(lyx::to_utf8(_("No information for editing %1$s")),
Alert::error(_("Cannot edit file"),
bformat(_("No information for editing %1$s"),
prettyName(format_name)));
return false;
}
@ -355,9 +356,9 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
if (os::autoOpenFile(filename, os::EDIT))
return true;
else {
Alert::error(lyx::to_utf8(_("Cannot edit file")),
bformat(lyx::to_utf8(_("Auto-edit file %1$s failed")),
filename));
Alert::error(_("Cannot edit file"),
bformat(_("Auto-edit file %1$s failed"),
lyx::from_utf8(filename)));
return false;
}
}
@ -371,14 +372,14 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
command = subst(command, token_path, quoteName(onlyPath(filename)));
command = subst(command, token_socket, quoteName(lyxsocket->address()));
lyxerr[Debug::FILES] << "Executing command: " << command << std::endl;
buffer.message(lyx::to_utf8(_("Executing command: ")) + command);
buffer.message(_("Executing command: ") + lyx::from_utf8(command));
Systemcall one;
int const res = one.startscript(Systemcall::DontWait, command);
if (res) {
Alert::error(lyx::to_utf8(_("Cannot edit file")),
bformat(lyx::to_utf8(_("An error occurred whilst running %1$s")),
Alert::error(_("Cannot edit file"),
bformat(_("An error occurred whilst running %1$s"),
makeDisplayPath(command, 50)));
return false;
}
@ -386,13 +387,13 @@ bool Formats::edit(Buffer const & buffer, string const & filename,
}
string const Formats::prettyName(string const & name) const
docstring const Formats::prettyName(string const & name) const
{
Format const * format = getFormat(name);
if (format)
return format->prettyname();
return lyx::from_utf8(format->prettyname());
else
return name;
return lyx::from_utf8(name);
}

View File

@ -12,6 +12,8 @@
#ifndef FORMAT_H
#define FORMAT_H
#include "support/docstring.h"
#include <vector>
#include <string>
@ -138,7 +140,7 @@ public:
bool edit(Buffer const & buffer, std::string const & filename,
std::string const & format_name) const;
///
std::string const prettyName(std::string const & name) const;
lyx::docstring const prettyName(std::string const & name) const;
///
std::string const extension(std::string const & name) const;
///

View File

@ -16,26 +16,28 @@
#include "debug.h"
#include "lyx_gui.h"
using lyx::docstring;
using std::endl;
using std::make_pair;
using std::pair;
using std::string;
int Alert::prompt(string const & title, string const & question,
int Alert::prompt(docstring const & title, docstring const & question,
int default_button, int escape_button,
string const & b1, string const & b2, string const & b3)
docstring const & b1, docstring const & b2, docstring const & b3)
{
if (!lyx_gui::use_gui || lyxerr.debugging()) {
lyxerr << title << '\n'
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< question << endl;
<< lyx::to_utf8(question) << endl;
lyxerr << "Assuming answer is ";
switch (default_button) {
case 0: lyxerr << b1 << endl;
case 1: lyxerr << b2 << endl;
case 2: lyxerr << b3 << endl;
case 0: lyxerr << lyx::to_utf8(b1) << endl;
case 1: lyxerr << lyx::to_utf8(b2) << endl;
case 2: lyxerr << lyx::to_utf8(b3) << endl;
}
if (!lyx_gui::use_gui)
return default_button;
@ -47,51 +49,51 @@ int Alert::prompt(string const & title, string const & question,
}
void Alert::warning(string const & title, string const & message)
void Alert::warning(docstring const & title, docstring const & message)
{
if (!lyx_gui::use_gui || lyxerr.debugging())
lyxerr << "Warning: " << title << '\n'
lyxerr << "Warning: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< message << endl;
<< lyx::to_utf8(message) << endl;
if (lyx_gui::use_gui)
warning_pimpl(title, message);
}
void Alert::error(string const & title, string const & message)
void Alert::error(docstring const & title, docstring const & message)
{
if (!lyx_gui::use_gui || lyxerr.debugging())
lyxerr << "Error: " << title << '\n'
lyxerr << "Error: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< message << endl;
<< lyx::to_utf8(message) << endl;
if (lyx_gui::use_gui)
error_pimpl(title, message);
}
void Alert::information(string const & title, string const & message)
void Alert::information(docstring const & title, docstring const & message)
{
if (!lyx_gui::use_gui || lyxerr.debugging())
lyxerr << title << '\n'
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< message << endl;
<< lyx::to_utf8(message) << endl;
if (lyx_gui::use_gui)
information_pimpl(title, message);
}
pair<bool, string> const Alert::askForText(string const & msg,
string const & dflt)
pair<bool, docstring> const Alert::askForText(docstring const & msg,
docstring const & dflt)
{
if (!lyx_gui::use_gui || lyxerr.debugging()) {
lyxerr << "----------------------------------------\n"
<< msg << '\n'
<< "Assuming answer is " << dflt << '\n'
<< lyx::to_utf8(msg) << '\n'
<< "Assuming answer is " << lyx::to_utf8(dflt) << '\n'
<< "----------------------------------------" << endl;
if (!lyx_gui::use_gui)
return make_pair<bool, string>(true, dflt);
return make_pair<bool, docstring>(true, dflt);
}
return askForText_pimpl(msg, dflt);

View File

@ -28,21 +28,21 @@ namespace Alert {
* "Yes" or "No", I will personally come around to your house and
* slap you with fish, and not in an enjoyable way either.
*/
int prompt(std::string const & title, std::string const & question,
int prompt(lyx::docstring const & title, lyx::docstring const & question,
int default_button, int cancel_button,
std::string const & b1, std::string const & b2, std::string const & b3 = std::string());
lyx::docstring const & b1, lyx::docstring const & b2, lyx::docstring const & b3 = lyx::docstring());
/**
* Display a warning to the user. Title should be a short (general) summary.
* Only use this if the user cannot perform some remedial action.
*/
void warning(std::string const & title, std::string const & message);
void warning(lyx::docstring const & title, lyx::docstring const & message);
/**
* Display a warning to the user. Title should be a short (general) summary.
* Only use this if the user cannot perform some remedial action.
*/
void error(std::string const & title, std::string const & message);
void error(lyx::docstring const & title, lyx::docstring const & message);
/**
* Informational message. Use very very sparingly. That is, you must
@ -50,12 +50,12 @@ void error(std::string const & title, std::string const & message);
* and reciting the Nicene Creed, whilst running uphill and also
* eating.
*/
void information(std::string const & title, std::string const & message);
void information(lyx::docstring const & title, lyx::docstring const & message);
/// Asks for a text. DO NOT USE !!
std::pair<bool, std::string> const
askForText(std::string const & msg,
std::string const & dflt = std::string());
std::pair<bool, lyx::docstring> const
askForText(lyx::docstring const & msg,
lyx::docstring const & dflt = lyx::docstring());
}

View File

@ -11,18 +11,20 @@
// GUI-specific implementations
#include "support/docstring.h"
#include <utility>
#include <string>
int prompt_pimpl(std::string const & title, std::string const & question,
int prompt_pimpl(lyx::docstring const & title, lyx::docstring const & question,
int default_button, int escape_button,
std::string const & b1,
std::string const & b2,
std::string const & b3);
lyx::docstring const & b1,
lyx::docstring const & b2,
lyx::docstring const & b3);
void warning_pimpl(std::string const & title, std::string const & warning);
void error_pimpl(std::string const & title, std::string const & warning);
void information_pimpl(std::string const & title, std::string const & warning);
void warning_pimpl(lyx::docstring const & title, lyx::docstring const & warning);
void error_pimpl(lyx::docstring const & title, lyx::docstring const & warning);
void information_pimpl(lyx::docstring const & title, lyx::docstring const & warning);
std::pair<bool, std::string> const askForText_pimpl(std::string const & msg, std::string const & dflt);
std::pair<bool, lyx::docstring> const askForText_pimpl(lyx::docstring const & msg, lyx::docstring const & dflt);

View File

@ -53,6 +53,7 @@
using lyx::frontend::Gui;
using lyx::frontend::WorkArea;
using lyx::docstring;
using lyx::support::bformat;
using lyx::support::makeDisplayPath;
using lyx::support::onlyFilename;
@ -313,21 +314,21 @@ void LyXView::updateLayoutChoice()
void LyXView::updateWindowTitle()
{
static string last_title = "LyX";
string maximize_title = "LyX";
string minimize_title = "LyX";
static docstring last_title = lyx::from_ascii("LyX");
docstring maximize_title = lyx::from_ascii("LyX");
docstring minimize_title = lyx::from_ascii("LyX");
if (view()->available()) {
string const cur_title = buffer()->fileName();
if (!cur_title.empty()) {
maximize_title += ": " + makeDisplayPath(cur_title, 30);
minimize_title = onlyFilename(cur_title);
maximize_title += lyx::from_ascii(": ") + makeDisplayPath(cur_title, 30);
minimize_title = lyx::from_utf8(onlyFilename(cur_title));
if (!buffer()->isClean()) {
maximize_title += lyx::to_utf8(_(" (changed)"));
minimize_title += '*';
maximize_title += _(" (changed)");
minimize_title += lyx::char_type('*');
}
if (buffer()->isReadonly())
maximize_title += lyx::to_utf8(_(" (read only)"));
maximize_title += _(" (read only)");
}
}

View File

@ -136,7 +136,7 @@ public:
boost::signal<void()> focus_command_buffer;
/// display a message in the view
virtual void message(std::string const &) = 0;
virtual void message(lyx::docstring const &) = 0;
/// clear any temporary message and replace with current status
virtual void clearMessage() = 0;
@ -188,7 +188,7 @@ private:
* @param t main window title
* @param it iconified (short) title
*/
virtual void setWindowTitle(std::string const & t, std::string const & it) = 0;
virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it) = 0;
/// called on timeout
void autoSave();

View File

@ -273,7 +273,7 @@ void WorkArea::dispatch(FuncRequest const & cmd0)
void WorkArea::resizeBufferView()
{
lyx_view_.busy(true);
lyx_view_.message(lyx::to_utf8(_("Formatting document...")));
lyx_view_.message(_("Formatting document..."));
buffer_view_->workAreaResize(width(), height());
lyx_view_.updateLayoutChoice();
redraw();
@ -412,7 +412,7 @@ void WorkArea::toggleCursor()
}
void WorkArea::displayMessage(std::string const & message)
void WorkArea::displayMessage(lyx::docstring const & message)
{
lyx_view_.message(message);
}

View File

@ -34,6 +34,8 @@ int const CursorShape = CursorShape;
#include "frontends/LyXKeySym.h"
#include "frontends/Timeout.h"
#include "support/docstring.h"
#include <boost/signals/trackable.hpp>
class BufferView;
@ -145,7 +147,7 @@ private:
///
void checkAndGreyOut();
///
void displayMessage(std::string const &);
void displayMessage(lyx::docstring const &);
/// buffer messages signal connection
boost::signals::connection message_connection_;

View File

@ -89,10 +89,10 @@ string const ControlAboutlyx::getVersion() const
<< lyx_release_date
<< ")\n"
<< lyx::to_utf8(_("Library directory: "))
<< makeDisplayPath(package().system_support())
<< lyx::to_utf8(makeDisplayPath(package().system_support()))
<< "\n"
<< lyx::to_utf8(_("User directory: "))
<< makeDisplayPath(package().user_support());
<< lyx::to_utf8(makeDisplayPath(package().user_support()));
return ss.str();
}

View File

@ -48,11 +48,11 @@ bool ControlErrorList::initialiseParams(string const & error_type)
{
Buffer * buf = kernel().bufferview()->buffer();
// FIXME UNICODE
string const title = bformat(lyx::to_utf8(_("%1$s Errors (%2$s)")),
lyx::to_utf8(_(error_type)),
buf->fileName());
docstring const title = bformat(_("%1$s Errors (%2$s)"),
_(error_type),
lyx::from_utf8(buf->fileName()));
errorlist_ = buf->errorList(error_type);
name_ = title;
name_ = lyx::to_utf8(title);
return true;
}

View File

@ -63,7 +63,7 @@ vector<string> const ControlRef::getBufferList() const
vector<string> buffers = bufferlist.getFileNames();
for (vector<string>::iterator it = buffers.begin();
it != buffers.end(); ++it) {
*it = makeDisplayPath(*it);
*it = lyx::to_utf8(makeDisplayPath(*it));
}
return buffers;

View File

@ -37,6 +37,7 @@
#include "support/textutils.h"
#include "support/convert.h"
#include "support/docstring.h"
#include "frontends/Alert.h"
@ -56,7 +57,8 @@ namespace frontend {
ControlSpellchecker::ControlSpellchecker(Dialog & parent)
: Dialog::Controller(parent), exitEarly_(false),
oldval_(0), newvalue_(0), count_(0)
{}
{
}
ControlSpellchecker::~ControlSpellchecker()
@ -109,8 +111,8 @@ bool ControlSpellchecker::initialiseParams(std::string const &)
if (!success) {
// FIXME UNICODE
Alert::error(lyx::to_utf8(_("Spellchecker error")),
lyx::to_utf8(_("The spellchecker could not be started\n"))
Alert::error(_("Spellchecker error"),
_("The spellchecker could not be started\n")
+ speller_->error());
speller_.reset(0);
}
@ -264,18 +266,16 @@ bool ControlSpellchecker::checkAlive()
if (speller_->alive() && speller_->error().empty())
return true;
string message;
// FIXME UNICODE
docstring message;
if (speller_->error().empty())
message = lyx::to_utf8(_("The spellchecker has died for some reason.\n"
"Maybe it has been killed."));
message = _("The spellchecker has died for some reason.\n"
"Maybe it has been killed.");
else
message = lyx::to_utf8(_("The spellchecker has failed.\n"))
+ speller_->error();
message = _("The spellchecker has failed.\n") + speller_->error();
dialog().CancelButton();
Alert::error(lyx::to_utf8(_("The spellchecker has failed")), message);
Alert::error(_("The spellchecker has failed"), message);
return false;
}
@ -287,15 +287,15 @@ void ControlSpellchecker::showSummary()
return;
}
string message;
docstring message;
// FIXME UNICODE
if (count_ != 1)
message = bformat(lyx::to_utf8(_("%1$d words checked.")), count_);
message = bformat(_("%1$d words checked."), count_);
else
message = lyx::to_utf8(_("One word checked."));
message = _("One word checked.");
dialog().CancelButton();
Alert::information(lyx::to_utf8(_("Spelling check completed")), message);
Alert::information(_("Spelling check completed"), message);
}

View File

@ -220,12 +220,12 @@ string const getAbbreviatedAuthor(InfoMap const & map, string const & key)
if (authors.size() == 2)
// FIXME UNICODE
return bformat(lyx::to_utf8(_("%1$s and %2$s")),
familyName(authors[0]), familyName(authors[1]));
return lyx::to_utf8(bformat(_("%1$s and %2$s"),
lyx::from_utf8(familyName(authors[0])), lyx::from_utf8(familyName(authors[1]))));
if (authors.size() > 2)
// FIXME UNICODE
return bformat(lyx::to_utf8(_("%1$s et al.")), familyName(authors[0]));
return lyx::to_utf8(bformat(_("%1$s et al."), lyx::from_utf8(familyName(authors[0]))));
return familyName(authors[0]);
}

View File

@ -61,8 +61,8 @@ void rescanTexStyles()
if (status == 0)
return;
// FIXME UNICODE
Alert::error(lyx::to_utf8(_("Could not update TeX information")),
bformat(lyx::to_utf8(_("The script `%s' failed.")), command));
Alert::error(_("Could not update TeX information"),
bformat(_("The script `%s' failed."), lyx::from_utf8(command)));
}

View File

@ -43,7 +43,7 @@ string translateShortcut(string const & str)
}
void warning_pimpl(string const & title, string const & message)
void warning_pimpl(docstring const & title, docstring const & message)
{
Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
true, Gtk::MESSAGE_WARNING,
@ -53,7 +53,7 @@ void warning_pimpl(string const & title, string const & message)
}
void error_pimpl(string const & title, string const & message)
void error_pimpl(docstring const & title, docstring const & message)
{
Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
true, Gtk::MESSAGE_ERROR,
@ -63,7 +63,7 @@ void error_pimpl(string const & title, string const & message)
}
void information_pimpl(string const & title, string const & message)
void information_pimpl(docstring const & title, docstring const & message)
{
Gtk::MessageDialog dlg(Glib::Markup::escape_text(Glib::locale_to_utf8(message)),
true, Gtk::MESSAGE_INFO,
@ -73,9 +73,9 @@ void information_pimpl(string const & title, string const & message)
}
int prompt_pimpl(string const & title, string const & question,
int prompt_pimpl(docstring const & title, docstring const & question,
int defaultButton, int /*escapeButton*/,
string const & b1, string const & b2, string const & b3)
docstring const & b1, docstring const & b2, docstring const & b3)
{
Glib::ustring gb1 = Glib::locale_to_utf8(translateShortcut(b1));
Glib::ustring gb2 = Glib::locale_to_utf8(translateShortcut(b2));

View File

@ -103,8 +103,8 @@ void GDocument::doBuild()
classcombo_.append_text(cit->description());
} else {
// FIXME UNICODE
string item =
bformat(lyx::to_utf8(_("Unavailable: %1$s")), cit->description());
docstring item =
bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description()));
classcombo_.append_text(item);
}
}

View File

@ -173,7 +173,7 @@ void GView::allowInput() const
}
void GView::message(string const & msg)
void GView::message(docstring const & msg)
{
minibuffer_->message(msg);
}
@ -185,7 +185,7 @@ void GView::updateStatusBar()
}
void GView::setWindowTitle(string const & t, string const & /*it*/)
void GView::setWindowTitle(docstring const & t, docstring const & /*it*/)
{
set_title(Glib::locale_to_utf8(t));
}

View File

@ -42,7 +42,7 @@ public:
virtual void prohibitInput() const;
virtual void allowInput() const;
virtual void message(std::string const &);
virtual void message(lyx::docstring const &);
bool on_delete_event(GdkEventAny * event);
void focusWorkArea() { workArea_->grab_focus(); }
@ -64,7 +64,7 @@ public:
private:
bool onFocusIn(GdkEventFocus * event);
virtual void setWindowTitle(std::string const & t, std::string const & it);
virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it);
// The top-most box containing all other boxes.
Gtk::VBox top_box_;

View File

@ -32,11 +32,11 @@ using std::make_pair;
using std::string;
int prompt_pimpl(string const & tit, string const & question,
int prompt_pimpl(docstring const & tit, docstring const & question,
int default_button, int cancel_button,
string const & b1, string const & b2, string const & b3)
docstring const & b1, docstring const & b2, docstring const & b3)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QWidget * const parent = qApp->focusWidget() ?
qApp->focusWidget() : qApp->mainWidget();
@ -56,49 +56,49 @@ int prompt_pimpl(string const & tit, string const & question,
}
void warning_pimpl(string const & tit, string const & message)
void warning_pimpl(docstring const & tit, docstring const & message)
{
QWidget * const parent = qApp->focusWidget() ?
qApp->focusWidget() : qApp->mainWidget();
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::warning(parent,
toqstr(title),
toqstr(formatted(message)));
}
void error_pimpl(string const & tit, string const & message)
void error_pimpl(docstring const & tit, docstring const & message)
{
QWidget * const parent = qApp->focusWidget() ?
qApp->focusWidget() : qApp->mainWidget();
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::critical(parent,
toqstr(title),
toqstr(formatted(message)));
}
void information_pimpl(string const & tit, string const & message)
void information_pimpl(docstring const & tit, docstring const & message)
{
QWidget * const parent = qApp->focusWidget() ?
qApp->focusWidget() : qApp->mainWidget();
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::information(parent,
toqstr(title),
toqstr(formatted(message)));
}
pair<bool, string> const
askForText_pimpl(string const & msg, string const & dflt)
pair<bool, docstring> const
askForText_pimpl(docstring const & msg, docstring const & dflt)
{
QWidget * const parent = qApp->focusWidget() ?
qApp->focusWidget() : qApp->mainWidget();
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), msg);
docstring const title = bformat(_("LyX: %1$s"), msg);
QAskForTextDialog d(parent, toqstr(title), true);
// less than ideal !
d.askLA->setText(toqstr('&' + msg));
@ -109,7 +109,7 @@ askForText_pimpl(string const & msg, string const & dflt)
d.hide();
if (ret)
return make_pair<bool, string>(true, fromqstr(d.askLE->text()));
return make_pair<bool, docstring>(true, qstring_to_ucs4(d.askLE->text()));
else
return make_pair<bool, string>(false, string());
return make_pair<bool, docstring>(false, docstring());
}

View File

@ -50,14 +50,14 @@ void QChanges::build_dialog()
void QChanges::update_contents()
{
string text;
string author(controller().getChangeAuthor());
string date(controller().getChangeDate());
docstring text;
docstring author = lyx::from_utf8(controller().getChangeAuthor());
docstring date = lyx::from_utf8(controller().getChangeDate());
if (!author.empty())
text += bformat(lyx::to_utf8(_("Change by %1$s\n\n")), author);
text += bformat(_("Change by %1$s\n\n"), author);
if (!date.empty())
text += bformat(lyx::to_utf8(_("Change made at %1$s\n")), date);
text += bformat(_("Change made at %1$s\n"), date);
dialog_->changeTV->setText(toqstr(text));
}

View File

@ -131,8 +131,8 @@ void QDocument::build_dialog()
if (cit->isTeXClassAvailable()) {
dialog_->latexModule->classCO->insertItem(toqstr(cit->description()));
} else {
string item =
bformat(lyx::to_utf8(_("Unavailable: %1$s")), cit->description());
docstring item =
bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description()));
dialog_->latexModule->classCO->insertItem(toqstr(item));
}
}

View File

@ -514,7 +514,7 @@ void QPrefsDialog::updateCopiers()
if (command.empty())
continue;
std::string const & fmt = it->first;
std::string const & pretty = form_->formats().prettyName(fmt);
lyx::docstring const pretty = form_->formats().prettyName(fmt);
copiersModule->AllCopiersLB->insertItem(toqstr(pretty));
}

View File

@ -95,7 +95,7 @@ void QtView::init()
}
void QtView::setWindowTitle(string const & t, string const & it)
void QtView::setWindowTitle(docstring const & t, docstring const & it)
{
setCaption(toqstr(t));
setIconText(toqstr(it));
@ -109,7 +109,7 @@ void QtView::addCommandBuffer(QWidget * parent)
}
void QtView::message(string const & str)
void QtView::message(docstring const & str)
{
statusBar()->message(toqstr(str));
statusbar_timer_.stop();

View File

@ -53,7 +53,7 @@ public:
Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
/// display a status message
virtual void message(std::string const & str);
virtual void message(lyx::docstring const & str);
/// clear status message
virtual void clearMessage();
@ -94,7 +94,7 @@ private:
* @param t main window title
* @param it iconified (short) title
*/
virtual void setWindowTitle(std::string const & t, std::string const & it);
virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it);
QTimer statusbar_timer_;

View File

@ -29,17 +29,17 @@
#include <algorithm>
using lyx::support::bformat;
using lyx::docstring;
using std::pair;
using std::make_pair;
using std::string;
int prompt_pimpl(string const & tit, string const & question,
int prompt_pimpl(docstring const & tit, docstring const & question,
int default_button, int cancel_button,
string const & b1, string const & b2, string const & b3)
docstring const & b1, docstring const & b2, docstring const & b3)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
// FIXME replace that with theApp->gui()->currentView()
int res = QMessageBox::information(qApp->focusWidget(),
@ -57,47 +57,47 @@ int prompt_pimpl(string const & tit, string const & question,
}
void warning_pimpl(string const & tit, string const & message)
void warning_pimpl(docstring const & tit, docstring const & message)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::warning(qApp->focusWidget(),
toqstr(title),
toqstr(formatted(message)));
}
void error_pimpl(string const & tit, string const & message)
void error_pimpl(docstring const & tit, docstring const & message)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::critical(qApp->focusWidget(),
toqstr(title),
toqstr(formatted(message)));
}
void information_pimpl(string const & tit, string const & message)
void information_pimpl(docstring const & tit, docstring const & message)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), tit);
docstring const title = bformat(_("LyX: %1$s"), tit);
QMessageBox::information(qApp->focusWidget(),
toqstr(title),
toqstr(formatted(message)));
}
pair<bool, string> const
askForText_pimpl(string const & msg, string const & dflt)
pair<bool, docstring> const
askForText_pimpl(docstring const & msg, docstring const & dflt)
{
string const title = bformat(lyx::to_utf8(_("LyX: %1$s")), msg);
docstring const title = bformat(_("LyX: %1$s"), msg);
bool ok;
QString text = QInputDialog::getText(qApp->focusWidget(),
toqstr(title),
toqstr('&' + msg),
toqstr(lyx::char_type('&') + msg),
QLineEdit::Normal,
toqstr(dflt), &ok);
if (ok && !text.isEmpty())
return make_pair<bool, string>(true, fromqstr(text));
return make_pair<bool, docstring>(true, qstring_to_ucs4(text));
else
return make_pair<bool, string>(false, string());
return make_pair<bool, docstring>(false, docstring());
}

View File

@ -114,7 +114,7 @@ void GuiView::updateMenu(QAction * /*action*/)
}
void GuiView::setWindowTitle(string const & t, string const & it)
void GuiView::setWindowTitle(docstring const & t, docstring const & it)
{
QMainWindow::setWindowTitle(toqstr(t));
QMainWindow::setWindowIconText(toqstr(it));
@ -129,7 +129,7 @@ void GuiView::addCommandBuffer(QToolBar * toolbar)
}
void GuiView::message(string const & str)
void GuiView::message(docstring const & str)
{
statusBar()->showMessage(toqstr(str));
statusbar_timer_.stop();

View File

@ -63,7 +63,7 @@ public:
Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb);
/// display a status message
virtual void message(std::string const & str);
virtual void message(lyx::docstring const & str);
/// clear status message
virtual void clearMessage();
@ -106,7 +106,7 @@ private:
* @param t main window title
* @param it iconified (short) title
*/
virtual void setWindowTitle(std::string const & t, std::string const & it);
virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it);
QTimer statusbar_timer_;

View File

@ -58,14 +58,14 @@ void QChanges::next()
{
controller().find();
string text;
string author(controller().getChangeAuthor());
string date(controller().getChangeDate());
docstring text;
docstring author = lyx::from_utf8(controller().getChangeAuthor());
docstring date = lyx::from_utf8(controller().getChangeDate());
if (!author.empty())
text += bformat(lyx::to_utf8(_("Change by %1$s\n\n")), author);
text += bformat(_("Change by %1$s\n\n"), author);
if (!date.empty())
text += bformat(lyx::to_utf8(_("Change made at %1$s\n")), date);
text += bformat(_("Change made at %1$s\n"), date);
dialog_->changeTB->setPlainText(toqstr(text));
}

View File

@ -362,8 +362,8 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
if (cit->isTeXClassAvailable()) {
latexModule->classCO->addItem(toqstr(cit->description()));
} else {
string item =
bformat(lyx::to_utf8(_("Unavailable: %1$s")), cit->description());
docstring item =
bformat(_("Unavailable: %1$s"), lyx::from_utf8(cit->description()));
latexModule->classCO->addItem(toqstr(item));
}
}

View File

@ -1493,9 +1493,9 @@ void PrefFileformats::remove_format()
return;
string const current_text = form_->formats().get(nr).name();
if (form_->converters().formatIsUsed(current_text)) {
Alert::error(lyx::to_utf8(_("Format in use")),
lyx::to_utf8(_("Cannot remove a Format used by a Converter. "
"Remove the converter first.")));
Alert::error(_("Format in use"),
_("Cannot remove a Format used by a Converter. "
"Remove the converter first."));
return;
}

View File

@ -46,8 +46,8 @@ void QSpellchecker::build_dialog()
void QSpellchecker::update_contents()
{
if (isVisible() || controller().exitEarly()) {
controller().check();
if (isVisible()) {
// controller().check();
}
}

View File

@ -193,53 +193,53 @@ string const fromqstr(QString const & str)
}
string const formatted(string const & text, int w)
docstring const formatted(docstring const & text, int w)
{
string sout;
docstring sout;
if (text.empty())
return sout;
string::size_type curpos = 0;
string line;
docstring::size_type curpos = 0;
docstring line;
for (;;) {
string::size_type const nxtpos1 = text.find(' ', curpos);
string::size_type const nxtpos2 = text.find('\n', curpos);
string::size_type const nxtpos = std::min(nxtpos1, nxtpos2);
docstring::size_type const nxtpos1 = text.find(' ', curpos);
docstring::size_type const nxtpos2 = text.find('\n', curpos);
docstring::size_type const nxtpos = std::min(nxtpos1, nxtpos2);
string const word =
nxtpos == string::npos ?
docstring const word =
nxtpos == docstring::npos ?
text.substr(curpos) :
text.substr(curpos, nxtpos - curpos);
bool const newline = (nxtpos2 != string::npos &&
bool const newline = (nxtpos2 != docstring::npos &&
nxtpos2 < nxtpos1);
string const line_plus_word =
line.empty() ? word : line + ' ' + word;
docstring const line_plus_word =
line.empty() ? word : line + lyx::char_type(' ') + word;
// FIXME: make w be size_t
if (int(line_plus_word.length()) >= w) {
sout += line + '\n';
sout += line + lyx::char_type('\n');
if (newline) {
sout += word + '\n';
sout += word + lyx::char_type('\n');
line.erase();
} else {
line = word;
}
} else if (newline) {
sout += line_plus_word + '\n';
sout += line_plus_word + lyx::char_type('\n');
line.erase();
} else {
if (!line.empty())
line += ' ';
line += lyx::char_type(' ');
line += word;
}
if (nxtpos == string::npos) {
if (nxtpos == docstring::npos) {
if (!line.empty())
sout += line;
break;

View File

@ -41,7 +41,7 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
std::string const & len, LyXLength::UNIT default_unit);
/// format a string to the given width
std::string const formatted(std::string const & text, int w = 80);
lyx::docstring const formatted(lyx::docstring const & text, int w = 80);
/**
* toqstr - convert char * into unicode

View File

@ -138,9 +138,9 @@ QValidator::State PathValidator::validate(QString & qtext, int &) const
static int counter = 0;
if (counter == 0) {
Alert::error(lyx::to_utf8(_("Invalid filename")),
lyx::to_utf8(_("LyX does not provide LateX support for file names containing any of these characters:\n")) +
printable_list(invalid_chars));
Alert::error(_("Invalid filename"),
_("LyX does not provide LateX support for file names containing any of these characters:\n") +
lyx::from_utf8(printable_list(invalid_chars)));
}
++counter;
return QValidator::Intermediate;

View File

@ -44,6 +44,12 @@ docstring const _(string const & str)
}
docstring const _(docstring const & str)
{
return getLyXMessages().get(lyx::to_utf8(str));
}
#ifdef ENABLE_NLS
void locale_init()

View File

@ -401,10 +401,10 @@ void CacheItem::Impl::convertToDisplayFormat()
} else
filename = filename_;
string const displayed_filename = makeDisplayPath(filename_);
docstring const displayed_filename = makeDisplayPath(filename_);
lyxerr[Debug::GRAPHICS] << "[GrahicsCacheItem::convertToDisplayFormat]\n"
<< "\tAttempting to convert image file: " << filename
<< "\n\twith displayed filename: " << displayed_filename
<< "\n\twith displayed filename: " << lyx::to_utf8(displayed_filename)
<< endl;
string const from = formats.getFormatFromFile(filename);

View File

@ -26,6 +26,7 @@
#include "BufferView.h"
#include "buffer_funcs.h"
using lyx::docstring;
using lyx::support::bformat;
using lyx::support::changeExtension;
using lyx::support::makeDisplayPath;
@ -41,8 +42,8 @@ extern BufferList bufferlist;
bool Importer::Import(LyXView * lv, string const & filename,
string const & format, ErrorList & errorList)
{
string const displaypath = makeDisplayPath(filename);
lv->message(bformat(lyx::to_utf8(_("Importing %1$s...")), displaypath));
docstring const displaypath = makeDisplayPath(filename);
lv->message(bformat(_("Importing %1$s..."), displaypath));
string const lyxfile = changeExtension(filename, ".lyx");
@ -60,8 +61,8 @@ bool Importer::Import(LyXView * lv, string const & filename,
}
}
if (loader_format.empty()) {
Alert::error(lyx::to_utf8(_("Couldn't import file")),
bformat(lyx::to_utf8(_("No information for importing the format %1$s.")),
Alert::error(_("Couldn't import file"),
bformat(_("No information for importing the format %1$s."),
formats.prettyName(format)));
return false;
}
@ -86,7 +87,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
}
// we are done
lv->message(lyx::to_utf8(_("imported.")));
lv->message(_("imported."));
return true;
}

View File

@ -192,9 +192,9 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
warned_about_spaces = true;
// FIXME UNICODE
Alert::warning(lyx::to_utf8(_("Export Warning!")),
lyx::to_utf8(_("There are spaces in the paths to your BibTeX databases.\n"
"BibTeX will be unable to find them.")));
Alert::warning(_("Export Warning!"),
_("There are spaces in the paths to your BibTeX databases.\n"
"BibTeX will be unable to find them."));
}
@ -244,9 +244,9 @@ int InsetBibtex::latex(Buffer const & buffer, ostream & os,
if (!warned_about_bst_spaces && runparams.nice && contains(style, ' ')) {
warned_about_bst_spaces = true;
// FIXME UNICODE
Alert::warning(lyx::to_utf8(_("Export Warning!")),
lyx::to_utf8(_("There are spaces in the path to your BibTeX style file.\n"
"BibTeX will be unable to find it.")));
Alert::warning(_("Export Warning!"),
_("There are spaces in the path to your BibTeX style file.\n"
"BibTeX will be unable to find it."));
}
if (!db_out.empty() && buffer.params().use_bibtopic){

View File

@ -113,7 +113,8 @@ void InsetCaption::setLabel(LCursor & cur) const
num = convert<string>(counter_);
// Generate the label
label = bformat("%1$s %2$s:", lyx::to_utf8(_(s)), num);
label = lyx::to_utf8(
bformat(lyx::from_ascii("%1$s %2$s:"), _(s), lyx::from_ascii(num)));
}
}

View File

@ -577,8 +577,8 @@ string const getScreenLabel(InsetExternalParams const & params,
external::getTemplatePtr(params);
if (!ptr)
// FIXME UNICODE
return support::bformat(lyx::to_utf8(_("External template %1$s is not installed")),
params.templatename());
return lyx::to_utf8(support::bformat(_("External template %1$s is not installed"),
lyx::from_utf8(params.templatename())));
return external::doSubstitution(params, buffer, ptr->guiName, false);
}

View File

@ -121,7 +121,7 @@ int InsetFloatList::latex(Buffer const & buf, ostream & os,
} else {
// FIXME UNICODE
os << "%%\\listof{" << getCmdName() << "}{"
<< bformat(lyx::to_utf8(_("List of %1$s")), cit->second.name())
<< lyx::to_utf8(bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name())))
<< "}\n";
}
return 1;

View File

@ -473,9 +473,9 @@ copyFileIfNeeded(string const & file_in, string const & file_out)
if (!success) {
// FIXME UNICODE
lyxerr[Debug::GRAPHICS]
<< support::bformat(lyx::to_utf8(_("Could not copy the file\n%1$s\n"
"into the temporary directory.")),
file_in)
<< lyx::to_utf8(support::bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."),
lyx::from_utf8(file_in)))
<< std::endl;
}
@ -706,8 +706,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
if (compare_timestamps(temp_file, to_file) < 0) {
// FIXME UNICODE
lyxerr[Debug::GRAPHICS]
<< bformat(lyx::to_utf8(_("No conversion of %1$s is needed after all")),
rel_file)
<< lyx::to_utf8(bformat(_("No conversion of %1$s is needed after all"),
lyx::from_utf8(rel_file)))
<< std::endl;
runparams.exportdata->addExternalFile(tex_format, to_file,
output_to_file);
@ -813,8 +813,8 @@ int InsetGraphics::plaintext(Buffer const &, ostream & os,
// 2. Read ascii output file and add it to the output stream.
// at least we send the filename
// FIXME UNICODE
os << '<' << bformat(lyx::to_utf8(_("Graphics file: %1$s")),
params().filename.absFilename()) << ">\n";
os << '<' << lyx::to_utf8(bformat(_("Graphics file: %1$s"),
lyx::from_utf8(params().filename.absFilename()))) << ">\n";
return 0;
}

View File

@ -391,13 +391,13 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
if (tmp->params().textclass != m_buffer->params().textclass) {
// FIXME UNICODE
string text = bformat(lyx::to_utf8(_("Included file `%1$s'\n"
docstring text = bformat(_("Included file `%1$s'\n"
"has textclass `%2$s'\n"
"while parent file has textclass `%3$s'.")),
"while parent file has textclass `%3$s'."),
makeDisplayPath(included_file),
tmp->params().getLyXTextClass().name(),
m_buffer->params().getLyXTextClass().name());
Alert::warning(lyx::to_utf8(_("Different textclasses")), text);
lyx::from_utf8(tmp->params().getLyXTextClass().name()),
lyx::from_utf8(m_buffer->params().getLyXTextClass().name()));
Alert::warning(_("Different textclasses"), text);
//return 0;
}
@ -424,9 +424,9 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
if (!copy(included_file, writefile)) {
// FIXME UNICODE
lyxerr[Debug::LATEX]
<< bformat(lyx::to_utf8(_("Could not copy the file\n%1$s\n"
"into the temporary directory.")),
included_file)
<< lyx::to_utf8(bformat(_("Could not copy the file\n%1$s\n"
"into the temporary directory."),
lyx::from_utf8(included_file)))
<< endl;
return 0;
}

View File

@ -1558,8 +1558,8 @@ void InsetTabular::tabularFeatures(LCursor & cur,
#warning Need I say it ? This is horrible.
#endif
// FIXME UNICODE
Alert::error(lyx::to_utf8(_("Error setting multicolumn")),
lyx::to_utf8(_("You cannot set multicolumn vertically.")));
Alert::error(_("Error setting multicolumn"),
_("You cannot set multicolumn vertically."));
return;
}
if (!cur.selection()) {

View File

@ -32,6 +32,8 @@
# include <sys/time.h>
#endif
using lyx::docstring;
using boost::shared_ptr;
#ifndef CXX_GLOBAL_CSTD
@ -203,14 +205,14 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
// This is what happens when goto gets banned.
if (pipe(pipein) == -1) {
error_ = lyx::to_utf8(_("Can't create pipe for spellchecker."));
error_ = _("Can't create pipe for spellchecker.");
return;
}
if (pipe(pipeout) == -1) {
close(pipein[0]);
close(pipein[1]);
error_ = lyx::to_utf8(_("Can't create pipe for spellchecker."));
error_ = _("Can't create pipe for spellchecker.");
return;
}
@ -219,22 +221,22 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
close(pipein[1]);
close(pipeout[0]);
close(pipeout[1]);
error_ = lyx::to_utf8(_("Can't create pipe for spellchecker."));
error_ = _("Can't create pipe for spellchecker.");
return;
}
if ((out = fdopen(pipein[1], "w")) == 0) {
error_ = lyx::to_utf8(_("Can't open pipe for spellchecker."));
error_ = _("Can't open pipe for spellchecker.");
return;
}
if ((in = fdopen(pipeout[0], "r")) == 0) {
error_ = lyx::to_utf8(_("Can't open pipe for spellchecker."));
error_ = _("Can't open pipe for spellchecker.");
return;
}
if ((inerr = fdopen(pipeerr[0], "r")) == 0) {
error_ = lyx::to_utf8(_("Can't open pipe for spellchecker."));
error_ = _("Can't open pipe for spellchecker.");
return;
}
@ -243,8 +245,8 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
LaunchIspell * li = new LaunchIspell(params, lang, pipein, pipeout, pipeerr);
child_.reset(li);
if (li->start() == -1) {
error_ = lyx::to_utf8(_("Could not create an ispell process.\nYou may not have "
"the right languages installed."));
error_ = _("Could not create an ispell process.\nYou may not have "
"the right languages installed.");
child_.reset(0);
return;
}
@ -262,10 +264,10 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
}
/* must have read something from stderr */
error_ = buf;
error_ =lyx::from_utf8(buf);
} else {
// select returned error
error_ = lyx::to_utf8(_("The ispell process returned an error.\nPerhaps "
error_ = _("The ispell process returned an error.\nPerhaps "
"it has been configured wrongly ?"));
}
@ -374,12 +376,12 @@ enum ISpell::Result ISpell::check(WordLangTuple const & word)
bool error = select(err_read);
if (error) {
error_ = lyx::to_utf8(_("Could not communicate with the ispell spellchecker process."));
error_ = _("Could not communicate with the ispell spellchecker process."));
return UNKNOWN_WORD;
}
if (err_read) {
error_ = buf;
error_ = lyx::from_utf8(buf);
return UNKNOWN_WORD;
}
@ -444,7 +446,7 @@ void ISpell::accept(WordLangTuple const & word)
}
string const ISpell::error()
docstring const ISpell::error()
{
return error_;
}

View File

@ -15,6 +15,8 @@
#include "SpellBase.h"
#include "support/docstring.h"
#include <boost/scoped_ptr.hpp>
#include <cstdio>
@ -49,7 +51,7 @@ public:
virtual std::string const nextMiss();
/// give an error message on messy exit
virtual std::string const error();
virtual lyx::docstring const error();
private:
/// read some data. Returns true on an error. Sets err_read
@ -72,7 +74,7 @@ private:
char buf[BUFSIZ];
/// spell error
std::string error_;
lyx::docstring error_;
boost::scoped_ptr<lyx::support::ForkedProcess> child_;

View File

@ -108,12 +108,12 @@ bool menuWrite(Buffer * buffer)
// FIXME: we don't tell the user *WHY* the save failed !!
string const file = makeDisplayPath(buffer->fileName(), 30);
docstring const file = makeDisplayPath(buffer->fileName(), 30);
string text = bformat(lyx::to_utf8(_("The document %1$s could not be saved.\n\n"
"Do you want to rename the document and try again?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Rename and save?")),
text, 0, 1, lyx::to_utf8(_("&Rename")), lyx::to_utf8(_("&Cancel")));
docstring text = bformat(_("The document %1$s could not be saved.\n\n"
"Do you want to rename the document and try again?"), file);
int const ret = Alert::prompt(_("Rename and save?"),
text, 0, 1, _("&Rename"), _("&Cancel"));
if (ret == 0)
return writeAs(buffer);
@ -162,11 +162,11 @@ bool writeAs(Buffer * buffer, string const & filename)
fname = filename;
if (fs::exists(fname)) {
string const file = makeDisplayPath(fname, 30);
string text = bformat(lyx::to_utf8(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Over-write document?")),
text, 0, 1, lyx::to_utf8(_("&Over-write")), lyx::to_utf8(_("&Cancel")));
docstring const file = makeDisplayPath(fname, 30);
docstring text = bformat(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?"), file);
int const ret = Alert::prompt(_("Over-write document?"),
text, 0, 1, _("&Over-write"), _("&Cancel"));
if (ret == 1)
return false;
@ -211,10 +211,10 @@ void quitLyX(bool noask)
lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl;
if (!destroyDir(package().temp_dir())) {
string const msg =
bformat(lyx::to_utf8(_("Unable to remove the temporary directory %1$s")),
package().temp_dir());
Alert::warning(lyx::to_utf8(_("Unable to remove temporary directory")), msg);
docstring const msg =
bformat(_("Unable to remove the temporary directory %1$s"),
lyx::from_utf8(package().temp_dir()));
Alert::warning(_("Unable to remove temporary directory"), msg);
}
lyx_gui::exit(0);
@ -246,7 +246,7 @@ private:
int AutoSaveBuffer::start()
{
command_ = bformat(lyx::to_utf8(_("Auto-saving %1$s")), fname_);
command_ = lyx::to_utf8(bformat(_("Auto-saving %1$s"), lyx::from_utf8(fname_)));
return run(DontWait);
}
@ -286,7 +286,7 @@ int AutoSaveBuffer::generateChild()
// but safe in the parent, so...
if (pid == -1)
// emit message signal.
bv_.buffer()->message(lyx::to_utf8(_("Autosave failed!")));
bv_.buffer()->message(_("Autosave failed!"));
}
}
if (pid == 0) { // we are the child so...
@ -313,7 +313,7 @@ void autoSave(BufferView * bv)
}
// emit message signal.
bv->buffer()->message(lyx::to_utf8(_("Autosaving current document...")));
bv->buffer()->message(_("Autosaving current document..."));
// create autosave filename
string fname = bv->buffer()->filePath();
@ -396,21 +396,21 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
}
if (!fs::is_readable(fname)) {
string const error = strerror(errno);
string const file = makeDisplayPath(fname, 50);
string const text = bformat(lyx::to_utf8(_("Could not read the specified document\n"
"%1$s\ndue to the error: %2$s")), file, error);
Alert::error(lyx::to_utf8(_("Could not read file")), text);
docstring const error = lyx::from_ascii(strerror(errno));
docstring const file = makeDisplayPath(fname, 50);
docstring const text = bformat(_("Could not read the specified document\n"
"%1$s\ndue to the error: %2$s"), file, error);
Alert::error(_("Could not read file"), text);
return string();
}
ifstream ifs(fname.c_str());
if (!ifs) {
string const error = strerror(errno);
string const file = makeDisplayPath(fname, 50);
string const text = bformat(lyx::to_utf8(_("Could not open the specified document\n"
"%1$s\ndue to the error: %2$s")), file, error);
Alert::error(lyx::to_utf8(_("Could not open file")), text);
docstring const error = lyx::from_ascii(strerror(errno));
docstring const file = makeDisplayPath(fname, 50);
docstring const text = bformat(_("Could not open the specified document\n"
"%1$s\ndue to the error: %2$s"), file, error);
Alert::error(_("Could not open file"), text);
return string();
}
@ -440,7 +440,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
void reconfigure(BufferView * bv)
{
// emit message signal.
bv->buffer()->message(lyx::to_utf8(_("Running configure...")));
bv->buffer()->message(_("Running configure..."));
// Run configure in user lyx directory
Path p(package().user_support());
@ -449,13 +449,13 @@ void reconfigure(BufferView * bv)
one.startscript(Systemcall::Wait, configure_command);
p.pop();
// emit message signal.
bv->buffer()->message(lyx::to_utf8(_("Reloading configuration...")));
bv->buffer()->message(_("Reloading configuration..."));
lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
// Re-read packages.lst
LaTeXFeatures::getAvailable();
Alert::information(lyx::to_utf8(_("System reconfigured")),
lyx::to_utf8(_("The system has been reconfigured.\n"
Alert::information(_("System reconfigured"),
_("The system has been reconfigured.\n"
"You need to restart LyX to make use of any\n"
"updated document class specifications.")));
"updated document class specifications."));
}

View File

@ -76,6 +76,8 @@ using lyx::support::prependEnvPath;
using lyx::support::rtrim;
using lyx::support::Systemcall;
using lyx::docstring;
namespace os = lyx::support::os;
namespace fs = boost::filesystem;
@ -120,9 +122,9 @@ void lyx_exit(int status)
void showFileError(string const & error)
{
Alert::warning(lyx::to_utf8(_("Could not read configuration file")),
bformat(lyx::to_utf8(_("Error while reading the configuration file\n%1$s.\n"
"Please check your installation.")), error));
Alert::warning(_("Could not read configuration file"),
bformat(_("Error while reading the configuration file\n%1$s.\n"
"Please check your installation."), lyx::from_utf8(error)));
}
@ -233,8 +235,9 @@ int LyX::exec2(int & argc, char * argv[])
// other than documents
for (int argi = 1; argi < argc ; ++argi) {
if (argv[argi][0] == '-') {
lyxerr << bformat(lyx::to_utf8(_("Wrong command line option `%1$s'. Exiting.")),
argv[argi]) << endl;
lyxerr << lyx::to_utf8(
bformat(_("Wrong command line option `%1$s'. Exiting."),
lyx::from_utf8(argv[argi]))) << endl;
return EXIT_FAILURE;
}
}
@ -468,9 +471,9 @@ static void error_handler(int err_sig)
void LyX::printError(ErrorItem const & ei)
{
std::cerr << lyx::to_utf8(_("LyX: ")) << ei.error
<< ':' << ei.description << std::endl;
docstring tmp = _("LyX: ") + ei.error + lyx::char_type(':')
+ ei.description;
std::cerr << lyx::to_utf8(tmp) << std::endl;
}
@ -578,11 +581,11 @@ bool LyX::init()
package().temp_dir() = createLyXTmpDir(lyxrc.tempdir_path);
if (package().temp_dir().empty()) {
Alert::error(lyx::to_utf8(_("Could not create temporary directory")),
bformat(lyx::to_utf8(_("Could not create a temporary directory in\n"
Alert::error(_("Could not create temporary directory"),
bformat(_("Could not create a temporary directory in\n"
"%1$s. Make sure that this\n"
"path exists and is writable and try again.")),
lyxrc.tempdir_path));
"path exists and is writable and try again."),
lyx::from_utf8(lyxrc.tempdir_path)));
// createLyXTmpDir() tries sufficiently hard to create a
// usable temp dir, so the probability to come here is
// close to zero. We therefore don't try to overcome this
@ -728,20 +731,20 @@ bool LyX::queryUserLyXDir(bool explicit_userdir)
// to create it. If the user says "no", then exit.
if (explicit_userdir &&
Alert::prompt(
lyx::to_utf8(_("Missing user LyX directory")),
bformat(lyx::to_utf8(_("You have specified a non-existent user "
_("Missing user LyX directory"),
bformat(_("You have specified a non-existent user "
"LyX directory, %1$s.\n"
"It is needed to keep your own configuration.")),
package().user_support()),
"It is needed to keep your own configuration."),
lyx::from_utf8(package().user_support())),
1, 0,
lyx::to_utf8(_("&Create directory")),
lyx::to_utf8(_("&Exit LyX")))) {
_("&Create directory"),
_("&Exit LyX"))) {
lyxerr << lyx::to_utf8(_("No user LyX directory. Exiting.")) << endl;
lyx_exit(EXIT_FAILURE);
}
lyxerr << bformat(lyx::to_utf8(_("LyX: Creating directory %1$s")),
package().user_support())
lyxerr << lyx::to_utf8(bformat(_("LyX: Creating directory %1$s"),
lyx::from_utf8(package().user_support())))
<< endl;
if (!createDirectory(package().user_support(), 0755)) {
@ -906,7 +909,7 @@ int parse_dbg(string const & arg, string const &)
Debug::showTags(lyxerr);
exit(0);
}
lyxerr << bformat(lyx::to_utf8(_("Setting debug level to %1$s")), arg) << endl;
lyxerr << lyx::to_utf8(bformat(_("Setting debug level to %1$s"), lyx::from_utf8(arg))) << endl;
lyxerr.level(Debug::value(arg));
Debug::showLevel(lyxerr, lyxerr.level());

View File

@ -138,7 +138,7 @@ bool findChange(DocIterator & cur)
bool searchAllowed(BufferView * bv, string const & str)
{
if (str.empty()) {
Alert::error(lyx::to_utf8(_("Search error")), lyx::to_utf8(_("Search string is empty")));
Alert::error(_("Search error"), _("Search string is empty"));
return false;
}
return bv->available();
@ -289,7 +289,7 @@ void find(BufferView * bv, FuncRequest const & ev)
if (!found)
// emit message signal.
bv->message(lyx::to_utf8(_("String not found!")));
bv->message(_("String not found!"));
}
@ -320,14 +320,14 @@ void replace(BufferView * bv, FuncRequest const & ev)
if (replace_count == 0) {
// emit message signal.
buf->message(lyx::to_utf8(_("String not found!")));
buf->message(_("String not found!"));
} else {
if (replace_count == 1) {
// emit message signal.
buf->message(lyx::to_utf8(_("String has been replaced.")));
buf->message(_("String has been replaced."));
} else {
string str = convert<string>(replace_count);
str += lyx::to_utf8(_(" strings have been replaced."));
docstring str = convert<docstring>(replace_count);
str += _(" strings have been replaced.");
// emit message signal.
buf->message(str);
}

View File

@ -507,21 +507,22 @@ string const LyXFont::stateText(BufferParams * params) const
if (color() != LColor::inherit)
os << lcolor.getGUIName(color()) << ", ";
if (emph() != INHERIT)
os << bformat(lyx::to_utf8(_("Emphasis %1$s, ")),
lyx::to_utf8(_(GUIMiscNames[emph()])));
os << lyx::to_utf8(bformat(_("Emphasis %1$s, "),
_(GUIMiscNames[emph()])));
if (underbar() != INHERIT)
os << bformat(lyx::to_utf8(_("Underline %1$s, ")),
lyx::to_utf8(_(GUIMiscNames[underbar()])));
os << lyx::to_utf8(bformat(_("Underline %1$s, "),
_(GUIMiscNames[underbar()])));
if (noun() != INHERIT)
os << bformat(lyx::to_utf8(_("Noun %1$s, ")),
lyx::to_utf8(_(GUIMiscNames[noun()])));
os << lyx::to_utf8(bformat(_("Noun %1$s, "),
_(GUIMiscNames[noun()])));
if (bits == inherit)
os << lyx::to_utf8(_("Default")) << ", ";
if (!params || (language() != params->language))
os << bformat(lyx::to_utf8(_("Language: %1$s, ")),
lyx::to_utf8(_(language()->display())));
os << lyx::to_utf8(bformat(_("Language: %1$s, "),
_(language()->display())));
if (number() != OFF)
os << bformat(lyx::to_utf8(_(" Number %1$s")), lyx::to_utf8(_(GUIMiscNames[number()])));
os << lyx::to_utf8(bformat(_(" Number %1$s"),
_(GUIMiscNames[number()])));
return rtrim(os.str(), ", ");
}

View File

@ -294,7 +294,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
// num_bytes == 0? (Lgb)
if (keyseq.length() > 1) {
owner->message(keyseq.print());
owner->message(lyx::from_utf8(keyseq.print()));
}
@ -317,7 +317,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
FuncRequest::KEYBOARD);
} else {
lyxerr[Debug::KEY] << "Unknown, !isText() - giving up" << endl;
owner->message(lyx::to_utf8(_("Unknown function.")));
owner->message(_("Unknown function."));
return;
}
}
@ -357,7 +357,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
buf = owner->buffer();
if (cmd.action == LFUN_NOACTION) {
flag.message(N_("Nothing to do"));
flag.message(lyx::from_utf8(N_("Nothing to do")));
flag.enabled(false);
return flag;
}
@ -375,21 +375,21 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
}
if (flag.unknown()) {
flag.message(N_("Unknown action"));
flag.message(lyx::from_utf8(N_("Unknown action")));
return flag;
}
if (!flag.enabled()) {
if (flag.message().empty())
flag.message(N_("Command disabled"));
flag.message(lyx::from_utf8(N_("Command disabled")));
return flag;
}
// Check whether we need a buffer
if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
// no, exit directly
flag.message(N_("Command not allowed with"
"out any document open"));
flag.message(lyx::from_utf8(N_("Command not allowed with"
"out any document open")));
flag.enabled(false);
return flag;
}
@ -631,7 +631,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
if (buf && buf->isReadonly()
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
flag.message(N_("Document is read-only"));
flag.message(lyx::from_utf8(N_("Document is read-only")));
flag.enabled(false);
}
@ -640,13 +640,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
&& lookupChangeType(cur, true) == Change::DELETED
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
flag.message(N_("This portion of the document is deleted."));
flag.message(lyx::from_utf8(N_("This portion of the document is deleted.")));
flag.enabled(false);
}
// the default error message if we disable the command
if (!flag.enabled() && flag.message().empty())
flag.message(N_("Command disabled"));
flag.message(lyx::from_utf8(N_("Command disabled")));
return flag;
}
@ -660,13 +660,13 @@ bool ensureBufferClean(BufferView * bv)
if (buf.isClean())
return true;
string const file = makeDisplayPath(buf.fileName(), 30);
string text = bformat(lyx::to_utf8(_("The document %1$s has unsaved "
docstring const file = makeDisplayPath(buf.fileName(), 30);
docstring text = bformat(_("The document %1$s has unsaved "
"changes.\n\nDo you want to save "
"the document?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Save changed document?")),
text, 0, 1, lyx::to_utf8(_("&Save")),
lyx::to_utf8(_("&Cancel")));
"the document?"), file);
int const ret = Alert::prompt(_("Save changed document?"),
text, 0, 1, _("&Save"),
_("&Cancel"));
if (ret == 0)
bv->owner()->dispatch(FuncRequest(LFUN_BUFFER_WRITE));
@ -677,10 +677,10 @@ bool ensureBufferClean(BufferView * bv)
void showPrintError(string const & name)
{
string str = bformat(lyx::to_utf8(_("Could not print the document %1$s.\n"
"Check that your printer is set up correctly.")),
docstring str = bformat(_("Could not print the document %1$s.\n"
"Check that your printer is set up correctly."),
makeDisplayPath(name, 50));
Alert::error(lyx::to_utf8(_("Print document failed")), str);
Alert::error(_("Print document failed"), str);
}
@ -699,10 +699,10 @@ void loadTextclass(string const & name)
lyx::textclass_type const tc = tc_pair.second;
if (!textclasslist[tc].load()) {
string s = bformat(lyx::to_utf8(_("The document could not be converted\n"
"into the document class %1$s.")),
textclasslist[tc].name());
Alert::error(lyx::to_utf8(_("Could not change class")), s);
docstring s = bformat(_("The document could not be converted\n"
"into the document class %1$s."),
lyx::from_utf8(textclasslist[tc].name()));
Alert::error(_("Could not change class"), s);
}
}
@ -765,7 +765,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
case LFUN_COMMAND_PREFIX:
owner->message(keyseq.printOptions());
owner->message(lyx::from_utf8(keyseq.printOptions()));
break;
case LFUN_COMMAND_EXECUTE:
@ -779,12 +779,12 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
if (view()->available())
// cancel any selection
dispatch(FuncRequest(LFUN_MARK_OFF));
setMessage(N_("Cancel"));
setMessage(lyx::from_utf8(N_("Cancel")));
break;
case LFUN_META_PREFIX:
meta_fake_bit = key_modifier::alt;
setMessage(keyseq.print());
setMessage(lyx::from_utf8(keyseq.print()));
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY:
@ -810,11 +810,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_BUFFER_WRITE:
if (!owner->buffer()->isUnnamed()) {
string const str = bformat(lyx::to_utf8(_("Saving document %1$s...")),
docstring const str = bformat(_("Saving document %1$s..."),
makeDisplayPath(owner->buffer()->fileName()));
owner->message(str);
menuWrite(owner->buffer());
owner->message(str + lyx::to_utf8(_(" done.")));
owner->message(str + _(" done."));
} else
writeAs(owner->buffer());
update = false;
@ -826,11 +826,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
break;
case LFUN_BUFFER_RELOAD: {
string const file = makeDisplayPath(view()->buffer()->fileName(), 20);
string text = bformat(lyx::to_utf8(_("Any changes will be lost. Are you sure "
"you want to revert to the saved version of the document %1$s?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Revert to saved document?")),
text, 0, 1, lyx::to_utf8(_("&Revert")), lyx::to_utf8(_("&Cancel")));
docstring const file = makeDisplayPath(view()->buffer()->fileName(), 20);
docstring text = bformat(_("Any changes will be lost. Are you sure "
"you want to revert to the saved version of the document %1$s?"), file);
int const ret = Alert::prompt(_("Revert to saved document?"),
text, 0, 1, _("&Revert"), _("&Cancel"));
if (ret == 0)
view()->reload();
@ -1027,7 +1027,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_HELP_OPEN: {
string const arg = argument;
if (arg.empty()) {
setErrorMessage(N_("Missing argument"));
setErrorMessage(lyx::from_utf8(N_("Missing argument")));
break;
}
string const fname = i18nLibFileSearch("doc", arg, "lyx");
@ -1036,7 +1036,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
<< arg << "'. Bad installation?" << endl;
break;
}
owner->message(bformat(lyx::to_utf8(_("Opening help file %1$s...")),
owner->message(bformat(_("Opening help file %1$s..."),
makeDisplayPath(fname)));
owner->loadLyXFile(fname, false);
break;
@ -1113,15 +1113,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// --- lyxserver commands ----------------------------
case LFUN_SERVER_GET_NAME:
setMessage(owner->buffer()->fileName());
setMessage(lyx::from_utf8(owner->buffer()->fileName()));
lyxerr[Debug::INFO] << "FNAME["
<< owner->buffer()->fileName()
<< "] " << endl;
break;
case LFUN_SERVER_NOTIFY:
dispatch_buffer = keyseq.print();
lyxserver->notifyClient(dispatch_buffer);
dispatch_buffer = lyx::from_utf8(keyseq.print());
lyxserver->notifyClient(lyx::to_utf8(dispatch_buffer));
break;
case LFUN_SERVER_GOTO_FILE_ROW: {
@ -1284,8 +1284,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_BUFFER_CHILD_OPEN: {
string const filename =
makeAbsPath(argument, owner->buffer()->filePath());
setMessage(N_("Opening child document ") +
makeDisplayPath(filename) + "...");
setMessage(lyx::from_utf8(N_("Opening child document ")) +
makeDisplayPath(filename) + lyx::from_ascii("..."));
view()->savePosition(0);
string const parentfilename = owner->buffer()->fileName();
if (bufferlist.exists(filename))
@ -1363,8 +1363,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
string lyx_name;
string const x11_name = split(argument, lyx_name, ' ');
if (lyx_name.empty() || x11_name.empty()) {
setErrorMessage(N_("Syntax: set-color <lyx_name>"
" <x11_name>"));
setErrorMessage(lyx::from_utf8(N_("Syntax: set-color <lyx_name>"
" <x11_name>")));
break;
}
@ -1374,9 +1374,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
if (!lcolor.setColor(lyx_name, x11_name)) {
setErrorMessage(
bformat(lyx::to_utf8(_("Set-color \"%1$s\" failed "
bformat(_("Set-color \"%1$s\" failed "
"- color is undefined or "
"may not be redefined")), lyx_name));
"may not be redefined"),
lyx::from_utf8(lyx_name)));
break;
}
@ -1394,7 +1395,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
case LFUN_MESSAGE:
owner->message(argument);
owner->message(lyx::from_utf8(argument));
break;
case LFUN_TOOLTIPS_TOGGLE:
@ -1487,10 +1488,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
if (defaults.writeFile(defaults.fileName()))
setMessage(lyx::to_utf8(_("Document defaults saved in "))
setMessage(_("Document defaults saved in ")
+ makeDisplayPath(fname));
else
setErrorMessage(lyx::to_utf8(_("Unable to save document defaults")));
setErrorMessage(_("Unable to save document defaults"));
break;
}
@ -1544,7 +1545,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// nothing to do
break;
owner->message(lyx::to_utf8(_("Converting document to new document class...")));
owner->message(_("Converting document to new document class..."));
recordUndoFullDocument(view());
buffer->params().textclass = new_class;
StableDocIterator backcur(view()->cursor());
@ -1614,11 +1615,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
}
if (!quitting)
sendDispatchMessage(lyx::to_utf8(_(getMessage())), cmd);
// FIXME UNICODE: _() does not support anything but ascii.
// Do we need a lyx::to_ascii() method?
sendDispatchMessage(_(lyx::to_utf8(getMessage())), cmd);
}
void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd)
void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
{
/* When an action did not originate from the UI/kbd, it makes
* sense to avoid updating the GUI. It turns out that this
@ -1634,13 +1637,13 @@ void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd)
|| cmd.origin == FuncRequest::COMMANDBUFFER);
if (cmd.action == LFUN_SELF_INSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
lyxerr[Debug::ACTION] << "dispatch msg is " << lyx::to_utf8(msg) << endl;
if (!msg.empty())
owner->message(msg);
return;
}
string dispatch_msg = msg;
docstring dispatch_msg = msg;
if (!dispatch_msg.empty())
dispatch_msg += ' ';
@ -1664,10 +1667,11 @@ void LyXFunc::sendDispatchMessage(string const & msg, FuncRequest const & cmd)
if (!comname.empty()) {
comname = rtrim(comname);
dispatch_msg += '(' + rtrim(comname) + ')';
dispatch_msg += lyx::from_utf8('(' + rtrim(comname) + ')');
}
lyxerr[Debug::ACTION] << "verbose dispatch msg " << dispatch_msg << endl;
lyxerr[Debug::ACTION] << "verbose dispatch msg "
<< lyx::to_utf8(dispatch_msg) << endl;
if (!dispatch_msg.empty())
owner->message(dispatch_msg);
}
@ -1768,7 +1772,7 @@ void LyXFunc::open(string const & fname)
// check selected filename
if (filename.empty()) {
owner->message(lyx::to_utf8(_("Canceled.")));
owner->message(_("Canceled."));
return;
}
} else
@ -1781,7 +1785,7 @@ void LyXFunc::open(string const & fname)
filename = fullpath;
}
string const disp_fn(makeDisplayPath(filename));
docstring const disp_fn = makeDisplayPath(filename);
// if the file doesn't exist, let the user create one
if (!fs::exists(filename)) {
@ -1792,13 +1796,13 @@ void LyXFunc::open(string const & fname)
return;
}
owner->message(bformat(lyx::to_utf8(_("Opening document %1$s...")), disp_fn));
owner->message(bformat(_("Opening document %1$s..."), disp_fn));
string str2;
docstring str2;
if (owner->loadLyXFile(filename)) {
str2 = bformat(lyx::to_utf8(_("Document %1$s opened.")), disp_fn);
str2 = bformat(_("Document %1$s opened."), disp_fn);
} else {
str2 = bformat(lyx::to_utf8(_("Could not open document %1$s")), disp_fn);
str2 = bformat(_("Could not open document %1$s"), disp_fn);
}
owner->message(str2);
}
@ -1823,17 +1827,17 @@ void LyXFunc::doImport(string const & argument)
initpath = trypath;
}
string const text = bformat(lyx::to_utf8(_("Select %1$s file to import")),
docstring const text = bformat(_("Select %1$s file to import"),
formats.prettyName(format));
FileDialog fileDlg(text,
FileDialog fileDlg(lyx::to_utf8(text),
LFUN_BUFFER_IMPORT,
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
string(lyxrc.document_path)),
make_pair(string(lyx::to_utf8(_("Examples|#E#e"))),
string(addPath(package().system_support(), "examples"))));
string const filter = formats.prettyName(format)
string const filter = lyx::to_utf8(formats.prettyName(format))
+ " (*." + formats.extension(format) + ')';
FileDialog::Result result =
@ -1848,7 +1852,7 @@ void LyXFunc::doImport(string const & argument)
// check selected filename
if (filename.empty())
owner->message(lyx::to_utf8(_("Canceled.")));
owner->message(_("Canceled."));
}
if (filename.empty())
@ -1862,7 +1866,7 @@ void LyXFunc::doImport(string const & argument)
// Check if the document already is open
if (lyx_gui::use_gui && bufferlist.exists(lyxfile)) {
if (!bufferlist.close(bufferlist.getBuffer(lyxfile), true)) {
owner->message(lyx::to_utf8(_("Canceled.")));
owner->message(_("Canceled."));
return;
}
}
@ -1870,15 +1874,15 @@ void LyXFunc::doImport(string const & argument)
// if the file exists already, and we didn't do
// -i lyx thefile.lyx, warn
if (fs::exists(lyxfile) && filename != lyxfile) {
string const file = makeDisplayPath(lyxfile, 30);
docstring const file = makeDisplayPath(lyxfile, 30);
string text = bformat(lyx::to_utf8(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Over-write document?")),
text, 0, 1, lyx::to_utf8(_("&Over-write")), lyx::to_utf8(_("&Cancel")));
docstring text = bformat(_("The document %1$s already exists.\n\n"
"Do you want to over-write that document?"), file);
int const ret = Alert::prompt(_("Over-write document?"),
text, 0, 1, _("&Over-write"), _("&Cancel"));
if (ret == 1) {
owner->message(lyx::to_utf8(_("Canceled.")));
owner->message(_("Canceled."));
return;
}
}
@ -1913,14 +1917,14 @@ void LyXFunc::closeBuffer()
// This function is bit problematic when it comes to NLS, to make the
// lyx servers client be language indepenent we must not translate
// strings sent to this func.
void LyXFunc::setErrorMessage(string const & m) const
void LyXFunc::setErrorMessage(docstring const & m) const
{
dispatch_buffer = m;
errorstat = true;
}
void LyXFunc::setMessage(string const & m) const
void LyXFunc::setMessage(docstring const & m) const
{
dispatch_buffer = m;
}

View File

@ -61,11 +61,11 @@ public:
/// True if lyxfunc reports an error
bool errorStat() const { return errorstat; }
/// Buffer to store result messages
void setMessage(std::string const & m) const;
void setMessage(lyx::docstring const & m) const;
/// Buffer to store result messages
void setErrorMessage(std::string const &) const;
void setErrorMessage(lyx::docstring const &) const;
/// Buffer to store result messages
std::string const getMessage() const { return dispatch_buffer; }
lyx::docstring const getMessage() const { return dispatch_buffer; }
/// Handle a accented char key sequence
void handleKeyFunc(kb_action action);
@ -93,10 +93,10 @@ private:
/** Buffer to store messages and result data. Is there a
good reason to have this one as static in Dispatch? (Ale)
*/
mutable std::string dispatch_buffer;
mutable lyx::docstring dispatch_buffer;
/// send a post-dispatch status message
void sendDispatchMessage(std::string const & msg,
void sendDispatchMessage(lyx::docstring const & msg,
FuncRequest const & ev);
// I think the following should be moved to BufferView. (Asger)

View File

@ -83,7 +83,7 @@ void LyXLex::Pimpl::printError(string const & message) const
{
string const tmpmsg = subst(message, "$$Token", getString());
lyxerr << "LyX: " << tmpmsg << " [around line " << lineno
<< " of file " << makeDisplayPath(name) << ']' << endl;
<< " of file " << lyx::to_utf8(makeDisplayPath(name)) << ']' << endl;
}

View File

@ -2294,7 +2294,8 @@ string const LyXRC::getDescription(LyXRCTags tag)
break;
case RC_NUMLASTFILES:
str = lyx::from_utf8(bformat(lyx::to_utf8(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu.")), maxlastfiles));
str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
maxlastfiles);
break;
case RC_PATH_PREFIX:

View File

@ -456,7 +456,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
serv->func->dispatch(FuncRequest(lyxaction.lookupFunc(cmd), arg));
string const rval = serv->func->getMessage();
string const rval = lyx::to_utf8(serv->func->getMessage());
//modified june 1999 stefano@zool.su.se:
//all commands produce an INFO or ERROR message

View File

@ -140,7 +140,7 @@ void LyXServerSocket::dataCallback(int fd)
if (key == "LYXCMD") {
string const cmd = line.substr(pos + 1);
func->dispatch(lyxaction.lookupFunc(cmd));
string const rval = func->getMessage();
string const rval = lyx::to_utf8(func->getMessage());
if (func->errorStat()) {
client->writeln("ERROR:" + cmd + ':' + rval);
} else {

View File

@ -31,6 +31,7 @@ namespace fs = boost::filesystem;
#include <sstream>
using lyx::docstring;
using lyx::support::libFileSearch;
using lyx::support::makeDisplayPath;
using lyx::support::quoteName;
@ -210,11 +211,11 @@ bool LyXTextClass::read(string const & filename, bool merge)
if (!merge)
lyxerr[Debug::TCLASS] << "Reading textclass "
<< makeDisplayPath(filename)
<< endl;
<< lyx::to_utf8(makeDisplayPath(filename))
<< endl;
else
lyxerr[Debug::TCLASS] << "Reading input file "
<< makeDisplayPath(filename)
<< lyx::to_utf8(makeDisplayPath(filename))
<< endl;
LyXLex lexrc(textClassTags,
@ -447,7 +448,7 @@ bool LyXTextClass::read(string const & filename, bool merge)
if (!merge) { // we are at top level here.
lyxerr[Debug::TCLASS] << "Finished reading textclass "
<< makeDisplayPath(filename)
<< lyx::to_utf8(makeDisplayPath(filename))
<< endl;
if (defaultlayout_.empty()) {
lyxerr << "Error: Textclass '" << name_
@ -477,7 +478,7 @@ bool LyXTextClass::read(string const & filename, bool merge)
} else
lyxerr[Debug::TCLASS] << "Finished reading input file "
<< makeDisplayPath(filename)
<< lyx::to_utf8(makeDisplayPath(filename))
<< endl;
return error;
@ -928,7 +929,7 @@ bool LyXTextClass::load(string const & path) const
if (!loaded_) {
lyxerr << "Error reading `"
<< makeDisplayPath(layout_file)
<< lyx::to_utf8(makeDisplayPath(layout_file))
<< "'\n(Check `" << name_
<< "')\nCheck your installation and "
"try Options/Reconfigure..." << endl;

View File

@ -104,7 +104,7 @@ bool LyXTextClassList::read()
if (real_file.empty()) {
lyxerr << "LyXTextClassList::Read: unable to find "
"textclass file `" << makeDisplayPath(real_file, 1000)
"textclass file `" << lyx::to_utf8(makeDisplayPath(real_file, 1000))
<< "'. Exiting." << endl;
return false;
// This causes LyX to end... Not a desirable behaviour. Lgb
@ -122,7 +122,7 @@ bool LyXTextClassList::read()
if (!lex.isOK()) {
lyxerr << "LyXTextClassList::Read: unable to open "
"textclass file `" << makeDisplayPath(real_file, 1000)
"textclass file `" << lyx::to_utf8(makeDisplayPath(real_file, 1000))
<< "'\nCheck your installation. LyX can't continue."
<< endl;
return false;

View File

@ -31,6 +31,8 @@ using lyx::support::isFileReadable;
using lyx::support::makeDisplayPath;
using lyx::support::tempName;
using lyx::docstring;
using std::endl;
using std::string;
using std::pair;
@ -90,9 +92,9 @@ void LyXVC::registrer()
// there must be a file to save
if (!isFileReadable(filename)) {
Alert::error(lyx::to_utf8(_("Document not saved")),
lyx::to_utf8(_("You must save the document "
"before it can be registered.")));
Alert::error(_("Document not saved"),
_("You must save the document "
"before it can be registered."));
return;
}
@ -103,14 +105,14 @@ void LyXVC::registrer()
if (isFileReadable(cvs_entries)) {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
<< makeDisplayPath(filename)
<< lyx::to_utf8(makeDisplayPath(filename))
<< " with CVS" << endl;
vcs.reset(new CVS(cvs_entries, filename));
} else {
lyxerr[Debug::LYXVC]
<< "LyXVC: registering "
<< makeDisplayPath(filename)
<< lyx::to_utf8(makeDisplayPath(filename))
<< " with RCS" << endl;
vcs.reset(new RCS(filename));
}
@ -119,16 +121,16 @@ void LyXVC::registrer()
}
lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
pair<bool, string> tmp =
Alert::askForText(lyx::to_utf8(_("LyX VC: Initial description")),
lyx::to_utf8(_("(no initial description)")));
pair<bool, docstring> tmp =
Alert::askForText(_("LyX VC: Initial description"),
_("(no initial description)"));
if (!tmp.first || tmp.second.empty()) {
// should we insist on checking tmp.second.empty()?
lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
return;
}
vcs->registrer(tmp.second);
vcs->registrer(lyx::to_utf8(tmp.second));
}
@ -136,12 +138,12 @@ void LyXVC::checkIn()
{
lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
pair<bool, string> tmp = Alert::askForText(lyx::to_utf8(_("LyX VC: Log Message")));
pair<bool, docstring> tmp = Alert::askForText(_("LyX VC: Log Message"));
if (tmp.first) {
if (tmp.second.empty()) {
tmp.second = lyx::to_utf8(_("(no log message)"));
tmp.second = _("(no log message)");
}
vcs->checkIn(tmp.second);
vcs->checkIn(lyx::to_utf8(tmp.second));
} else {
lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
}
@ -160,12 +162,12 @@ void LyXVC::revert()
{
lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
string const file = makeDisplayPath(owner_->fileName(), 20);
string text = bformat(lyx::to_utf8(_("Reverting to the stored version of the "
docstring const file = makeDisplayPath(owner_->fileName(), 20);
docstring text = bformat(_("Reverting to the stored version of the "
"document %1$s will lose all current changes.\n\n"
"Do you want to revert to the saved version?")), file);
int const ret = Alert::prompt(lyx::to_utf8(_("Revert to stored version of document?")),
text, 0, 1, lyx::to_utf8(_("&Revert")), lyx::to_utf8(_("&Cancel")));
"Do you want to revert to the saved version?"), file);
int const ret = Alert::prompt(_("Revert to stored version of document?"),
text, 0, 1, _("&Revert"), _("&Cancel"));
if (ret == 0)
vcs->revert();

View File

@ -117,7 +117,7 @@ void InsetFormulaMacro::read(std::istream & is)
string InsetFormulaMacro::prefix() const
{
return bformat(_(" Macro: %1$s: "), name_);
return lyx::to_utf8(bformat(_(" Macro: %1$s: "), lyx::from_utf8(name_)));
}

View File

@ -108,8 +108,8 @@ bool MathAMSArrayInset::getStatus(LCursor & cur, FuncRequest const & cmd,
docstring const & s = cmd.argument();
if (s == "add-vline-left" || s == "add-vline-right") {
flag.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"),
name_));
lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
lyx::from_utf8(name_)));
flag.enabled(false);
return true;
}

View File

@ -91,7 +91,8 @@ bool MathCasesInset::getStatus(LCursor & cur, FuncRequest const & cmd,
if (s == "add-vline-left" || s == "add-vline-right") {
flag.enabled(false);
flag.message(bformat(
N_("No vertical grid lines in '%1$s'"), lyx::to_utf8(s)));
lyx::from_utf8(N_("No vertical grid lines in '%1$s'")),
s));
return true;
}
}

View File

@ -1204,8 +1204,7 @@ void MathGridInset::doDispatch(LCursor & cur, FuncRequest & cmd)
}
case LFUN_PASTE: {
// FIXME UNICODE
cur.message(lyx::to_utf8(_("Paste")));
cur.message(_("Paste"));
lyx::cap::replaceSelection(cur);
istringstream is(lyx::to_utf8(cmd.argument()));
int n = 0;
@ -1303,13 +1302,13 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
string const s = lyx::to_utf8(cmd.argument());
if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) {
status.enabled(false);
status.message(N_("Only one row"));
status.message(lyx::from_utf8(N_("Only one row")));
return true;
}
if (ncols() <= 1 &&
(s == "delete-column" || s == "swap-column")) {
status.enabled(false);
status.message(N_("Only one column"));
status.message(lyx::from_utf8(N_("Only one column")));
return true;
}
if ((rowinfo_[cur.row()].lines_ == 0 &&
@ -1317,7 +1316,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
(rowinfo_[cur.row() + 1].lines_ == 0 &&
s == "delete-hline-below")) {
status.enabled(false);
status.message(N_("No hline to delete"));
status.message(lyx::from_utf8(N_("No hline to delete")));
return true;
}
@ -1326,7 +1325,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
(colinfo_[cur.col() + 1].lines_ == 0 &&
s == "delete-vline-right")) {
status.enabled(false);
status.message(N_("No vline to delete"));
status.message(lyx::from_utf8(N_("No vline to delete")));
return true;
}
if (s == "valign-top" || s == "valign-middle" ||
@ -1344,7 +1343,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
else {
status.enabled(false);
status.message(bformat(
N_("Unknown tabular feature '%1$s'"), s));
lyx::from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
}
status.setOnOff(s == "align-left" && halign(cur.col()) == 'l'

View File

@ -1042,8 +1042,8 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
else
for (row_type row = 0; row < nrows(); ++row)
numbered(row, !old);
// FIXME UNICODE
cur.message(old ? lyx::to_utf8(_("No number")) : lyx::to_utf8(_("Number")));
cur.message(old ? _("No number") : _("Number"));
}
break;
@ -1052,8 +1052,7 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd)
recordUndoInset(cur);
row_type r = (type_ == hullMultline) ? nrows() - 1 : cur.row();
bool old = numbered(r);
// FIXME UNICODE
cur.message(old ? lyx::to_utf8(_("No number")) : lyx::to_utf8(_("Number")));
cur.message(old ? _("No number") : _("Number"));
numbered(r, !old);
}
break;
@ -1186,8 +1185,8 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|| s == "delete-row"
|| s == "copy-row")) {
status.message(bformat(
N_("Can't change number of rows in '%1$s'"),
hullName(type_)));
lyx::from_utf8(N_("Can't change number of rows in '%1$s'")),
lyx::from_utf8(hullName(type_))));
status.enabled(false);
return true;
}
@ -1196,8 +1195,8 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|| s == "delete-column"
|| s == "copy-column")) {
status.message(bformat(
N_("Can't change number of columns in '%1$s'"),
hullName(type_)));
lyx::from_utf8(N_("Can't change number of columns in '%1$s'")),
lyx::from_utf8(hullName(type_))));
status.enabled(false);
return true;
}
@ -1206,15 +1205,15 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|| type_ == hullNone) &&
(s == "add-hline-above" || s == "add-hline-below")) {
status.message(bformat(
N_("Can't add horizontal grid lines in '%1$s'"),
hullName(type_)));
lyx::from_utf8(N_("Can't add horizontal grid lines in '%1$s'")),
lyx::from_utf8(hullName(type_))));
status.enabled(false);
return true;
}
if (s == "add-vline-left" || s == "add-vline-right") {
status.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"),
hullName(type_)));
lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
lyx::from_utf8(hullName(type_))));
status.enabled(false);
return true;
}
@ -1322,7 +1321,7 @@ void MathHullInset::revealCodes(LCursor & cur) const
return;
ostringstream os;
cur.info(os);
cur.message(os.str());
cur.message(lyx::from_utf8(os.str()));
/*
// write something to the minibuffer
// translate to latex

View File

@ -107,7 +107,7 @@ docstring MathMacroTemplate::prefix() const
// FIXME UNICODE
// delete the conversion when bformat() will return a docstring.
// delete the conversion when bformat() takes a docstring arg.
return lyx::from_utf8(bformat(lyx::to_utf8(_(" Macro: %1$s: ")), name_));
return bformat(_(" Macro: %1$s: "), lyx::from_utf8(name_));
}

View File

@ -421,8 +421,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
case LFUN_PASTE: {
recordUndo(cur);
// FIXME UNICODE
cur.message(lyx::to_utf8(_("Paste")));
cur.message(_("Paste"));
replaceSelection(cur);
size_t n = 0;
istringstream is(lyx::to_utf8(cmd.argument()));
@ -438,8 +437,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
case LFUN_CUT:
recordUndo(cur);
cutSelection(cur, true, true);
// FIXME UNICODE
cur.message(lyx::to_utf8(_("Cut")));
cur.message(_("Cut"));
// Prevent stale position >= size crash
// Probably not necessary anymore, see eraseSelection (gb 2005-10-09)
cur.normalize();
@ -448,7 +446,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
case LFUN_COPY:
copySelection(cur);
// FIXME UNICODE
cur.message(lyx::to_utf8(_("Copy")));
cur.message(_("Copy"));
break;
case LFUN_MOUSE_PRESS:

View File

@ -72,8 +72,8 @@ bool MathSplitInset::getStatus(LCursor & cur, FuncRequest const & cmd,
docstring const & s = cmd.argument();
if (s == "add-vline-left" || s == "add-vline-right") {
flag.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"),
name_));
lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
lyx::from_utf8(name_)));
flag.enabled(false);
return true;
}

View File

@ -67,7 +67,7 @@ bool MathSubstackInset::getStatus(LCursor & cur, FuncRequest const & cmd,
docstring const & s = cmd.argument();
if (s == "add-vline-left" || s == "add-vline-right") {
flag.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"), name));
lyx::from_utf8(N_("Can't add vertical grid lines in '%1$s'")), lyx::from_utf8(name)));
flag.enabled(false);
return true;
}

View File

@ -23,6 +23,8 @@
using lyx::support::bformat;
using lyx::support::makeDisplayPath;
using lyx::docstring;
using std::ofstream;
using std::string;
@ -30,10 +32,10 @@ bool openFileWrite(ofstream & ofs, string const & fname)
{
ofs.open(fname.c_str());
if (!ofs) {
string const file = makeDisplayPath(fname, 50);
string text = bformat(lyx::to_utf8(_("Could not open the specified "
"document\n%1$s.")), file);
Alert::error(lyx::to_utf8(_("Could not open file")), text);
docstring const file = makeDisplayPath(fname, 50);
docstring text = bformat(_("Could not open the specified "
"document\n%1$s."), file);
Alert::error(_("Could not open file"), text);
return false;
}
return true;

View File

@ -24,6 +24,8 @@ extern "C" {
#include <boost/assert.hpp>
using lyx::docstring;
using std::endl;
using std::string;
@ -141,7 +143,7 @@ string const PSpell::nextMiss()
}
string const PSpell::error()
docstring const PSpell::error()
{
char const * err = 0;

View File

@ -53,7 +53,7 @@ public:
virtual std::string const nextMiss();
/// give an error message on messy exit
virtual std::string const error();
virtual lyx::docstring const error();
private:
/// add a manager of the given language

Some files were not shown because too many files have changed in this diff Show More