diff --git a/development/cmake/src/support/package.C.cmake b/development/cmake/src/support/package.C.cmake index 690943974b..f666e6eceb 100644 --- a/development/cmake/src/support/package.C.cmake +++ b/development/cmake/src/support/package.C.cmake @@ -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; } diff --git a/src/BufferView.h b/src/BufferView.h index 9989b826a1..83d1c18586 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -218,7 +218,7 @@ public: void updateMetrics(bool singlepar = false); /// This signal is emitted when some message shows up. - boost::signal message; + boost::signal message; private: /// diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 136a45e19d..6009490263 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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; diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 32e862797c..eeb7e8f0e6 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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 diff --git a/src/FuncStatus.C b/src/FuncStatus.C index 2f0cf8e064..5961ec27c0 100644 --- a/src/FuncStatus.C +++ b/src/FuncStatus.C @@ -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_; } diff --git a/src/FuncStatus.h b/src/FuncStatus.h index 054b7db818..b632db5471 100644 --- a/src/FuncStatus.h +++ b/src/FuncStatus.h @@ -12,7 +12,7 @@ #ifndef FUNC_STATUS_H #define FUNC_STATUS_H -#include +#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 diff --git a/src/LaTeX.C b/src/LaTeX.C index 5c5a966eb4..2fd28a0388 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -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); } diff --git a/src/LaTeX.h b/src/LaTeX.h index c7d51e92a6..2860e68d6c 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -126,7 +126,7 @@ public: }; /// This signal emits an informative message - boost::signal message; + boost::signal message; /** diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 153905d588..05a4e82fb7 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -438,7 +438,7 @@ void expandLastfiles(Menu & tomenu, LyXView const * view) for (; lfit != lf.end() && ii < 10; ++lfit, ++ii) { docstring const label = convert(ii) + lyx::from_ascii(". ") - + lyx::from_utf8(makeDisplayPath((*lfit), 30)) + + makeDisplayPath((*lfit), 30) + char_type('|') + convert(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(ii) + lyx::from_ascii(". ") + label + char_type('|') + convert(ii); tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit)), view); diff --git a/src/SpellBase.C b/src/SpellBase.C index 3fbe175154..3ae16cde96 100644 --- a/src/SpellBase.C +++ b/src/SpellBase.C @@ -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."); } diff --git a/src/SpellBase.h b/src/SpellBase.h index 5eee2f6677..ca84c460d4 100644 --- a/src/SpellBase.h +++ b/src/SpellBase.h @@ -13,6 +13,8 @@ #ifndef SPELL_BASE_H #define SPELL_BASE_H +#include "support/docstring.h" + #include 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 diff --git a/src/aspell.C b/src/aspell.C index be2dc6ae98..1d711a3bf4 100644 --- a/src/aspell.C +++ b/src/aspell.C @@ -20,6 +20,8 @@ #include +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()); } diff --git a/src/aspell_local.h b/src/aspell_local.h index 7bfcd01238..c6a68931b1 100644 --- a/src/aspell_local.h +++ b/src/aspell_local.h @@ -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 diff --git a/src/buffer.C b/src/buffer.C index 21b8b37aaa..23f2405d21 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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"]); diff --git a/src/buffer.h b/src/buffer.h index d9dbf8863c..2c52c7b04c 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -117,7 +117,7 @@ public: /// This signal is emitted when some parsing error shows up. boost::signal errors; /// This signal is emitted when some message shows up. - boost::signal message; + boost::signal message; /// This signal is emitted when the buffer busy status change. boost::signal busy; /// This signal is emitted when the buffer readonly status change. diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 0de992187c..d6eb708eff 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -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 diff --git a/src/bufferlist.C b/src/bufferlist.C index ae1057bfcf..ed749a0312 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -34,6 +34,7 @@ #include #include +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. diff --git a/src/bufferparams.C b/src/bufferparams.C index 243a7df3a6..9b14b59695 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -47,6 +47,8 @@ #include 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); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 8669126de9..2125c5706b 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -300,7 +300,7 @@ void gotoInset(BufferView * bv, vector 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; } diff --git a/src/client/debug.C b/src/client/debug.C index f3bb53532e..ac42a27c6f 100644 --- a/src/client/debug.C +++ b/src/client/debug.C @@ -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'; } } diff --git a/src/converter.C b/src/converter.C index ad54732087..f6e51c1421 100644 --- a/src/converter.C +++ b/src/converter.C @@ -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, public boost::signals::trackable { +class showMessage : public std::unary_function, 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.")); } diff --git a/src/cursor.C b/src/cursor.C index d59de28474..9e52a22d24 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -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); } diff --git a/src/cursor.h b/src/cursor.h index 8238f2422a..ed6a35c686 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -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(); diff --git a/src/debug.C b/src/debug.C index f27ee93942..6f3e594d8a 100644 --- a/src/debug.C +++ b/src/debug.C @@ -20,6 +20,7 @@ #include #include +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; diff --git a/src/debug.h b/src/debug.h index c338b7a228..00998caa13 100644 --- a/src/debug.h +++ b/src/debug.h @@ -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. diff --git a/src/errorlist.C b/src/errorlist.C index 89bc1c1ee2..242ccb6abc 100644 --- a/src/errorlist.C +++ b/src/errorlist.C @@ -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_) diff --git a/src/errorlist.h b/src/errorlist.h index bd9bd1e330..39ab893f7d 100644 --- a/src/errorlist.h +++ b/src/errorlist.h @@ -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(); }; diff --git a/src/exporter.C b/src/exporter.C index 73e257be52..5e6b2aad6a 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -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 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))); } } diff --git a/src/format.C b/src/format.C index f4e88d68ad..2ce250db95 100644 --- a/src/format.C +++ b/src/format.C @@ -27,6 +27,7 @@ #include +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); } diff --git a/src/format.h b/src/format.h index 1b025a60e8..8a888e4431 100644 --- a/src/format.h +++ b/src/format.h @@ -12,6 +12,8 @@ #ifndef FORMAT_H #define FORMAT_H +#include "support/docstring.h" + #include #include @@ -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; /// diff --git a/src/frontends/Alert.C b/src/frontends/Alert.C index 83e6d33610..3bae1126f4 100644 --- a/src/frontends/Alert.C +++ b/src/frontends/Alert.C @@ -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 const Alert::askForText(string const & msg, - string const & dflt) +pair 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(true, dflt); + return make_pair(true, dflt); } return askForText_pimpl(msg, dflt); diff --git a/src/frontends/Alert.h b/src/frontends/Alert.h index 607c28126e..716b1a700b 100644 --- a/src/frontends/Alert.h +++ b/src/frontends/Alert.h @@ -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 const -askForText(std::string const & msg, - std::string const & dflt = std::string()); +std::pair const +askForText(lyx::docstring const & msg, + lyx::docstring const & dflt = lyx::docstring()); } diff --git a/src/frontends/Alert_pimpl.h b/src/frontends/Alert_pimpl.h index 5ccaa6cff8..96f8381b48 100644 --- a/src/frontends/Alert_pimpl.h +++ b/src/frontends/Alert_pimpl.h @@ -11,18 +11,20 @@ // GUI-specific implementations +#include "support/docstring.h" + #include #include -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 const askForText_pimpl(std::string const & msg, std::string const & dflt); +std::pair const askForText_pimpl(lyx::docstring const & msg, lyx::docstring const & dflt); diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 35ad7bce60..8989471f45 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -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)"); } } diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 726175f249..0ef9ee778f 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -136,7 +136,7 @@ public: boost::signal 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(); diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index c7fc36dfd7..cf7eac4b07 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -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); } diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 6f6d360773..d7b7fe0f6a 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -34,6 +34,8 @@ int const CursorShape = CursorShape; #include "frontends/LyXKeySym.h" #include "frontends/Timeout.h" +#include "support/docstring.h" + #include 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_; diff --git a/src/frontends/controllers/ControlAboutlyx.C b/src/frontends/controllers/ControlAboutlyx.C index 9d375777de..0cec62e1b3 100644 --- a/src/frontends/controllers/ControlAboutlyx.C +++ b/src/frontends/controllers/ControlAboutlyx.C @@ -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(); } diff --git a/src/frontends/controllers/ControlErrorList.C b/src/frontends/controllers/ControlErrorList.C index a76a310977..5b4f9e69a6 100644 --- a/src/frontends/controllers/ControlErrorList.C +++ b/src/frontends/controllers/ControlErrorList.C @@ -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; } diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index e17044a30d..0222e32650 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -63,7 +63,7 @@ vector const ControlRef::getBufferList() const vector buffers = bufferlist.getFileNames(); for (vector::iterator it = buffers.begin(); it != buffers.end(); ++it) { - *it = makeDisplayPath(*it); + *it = lyx::to_utf8(makeDisplayPath(*it)); } return buffers; diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 26a2cf4c91..964773abee 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -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); } diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index 813000a0c3..a4f16144e6 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -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]); } diff --git a/src/frontends/controllers/tex_helpers.C b/src/frontends/controllers/tex_helpers.C index 7046a8e229..ac61949453 100644 --- a/src/frontends/controllers/tex_helpers.C +++ b/src/frontends/controllers/tex_helpers.C @@ -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))); } diff --git a/src/frontends/gtk/Alert_pimpl.C b/src/frontends/gtk/Alert_pimpl.C index ac6a19c4d4..0abc9bb3e3 100644 --- a/src/frontends/gtk/Alert_pimpl.C +++ b/src/frontends/gtk/Alert_pimpl.C @@ -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)); diff --git a/src/frontends/gtk/GDocument.C b/src/frontends/gtk/GDocument.C index 3afbd20c2a..d683a6f800 100644 --- a/src/frontends/gtk/GDocument.C +++ b/src/frontends/gtk/GDocument.C @@ -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); } } diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index 83fe0fc557..ebd53ad78e 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -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)); } diff --git a/src/frontends/gtk/GView.h b/src/frontends/gtk/GView.h index e222049036..e73b45eafd 100644 --- a/src/frontends/gtk/GView.h +++ b/src/frontends/gtk/GView.h @@ -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_; diff --git a/src/frontends/qt3/Alert_pimpl.C b/src/frontends/qt3/Alert_pimpl.C index 2e0986b085..9025b6abf3 100644 --- a/src/frontends/qt3/Alert_pimpl.C +++ b/src/frontends/qt3/Alert_pimpl.C @@ -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 const -askForText_pimpl(string const & msg, string const & dflt) +pair 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(true, fromqstr(d.askLE->text())); + return make_pair(true, qstring_to_ucs4(d.askLE->text())); else - return make_pair(false, string()); + return make_pair(false, docstring()); } diff --git a/src/frontends/qt3/QChanges.C b/src/frontends/qt3/QChanges.C index f465799df2..4fcaad12d9 100644 --- a/src/frontends/qt3/QChanges.C +++ b/src/frontends/qt3/QChanges.C @@ -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)); } diff --git a/src/frontends/qt3/QDocument.C b/src/frontends/qt3/QDocument.C index 922435f7db..3426c4f55c 100644 --- a/src/frontends/qt3/QDocument.C +++ b/src/frontends/qt3/QDocument.C @@ -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)); } } diff --git a/src/frontends/qt3/QPrefsDialog.C b/src/frontends/qt3/QPrefsDialog.C index 7c58329b78..7da5eeeef1 100644 --- a/src/frontends/qt3/QPrefsDialog.C +++ b/src/frontends/qt3/QPrefsDialog.C @@ -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)); } diff --git a/src/frontends/qt3/QtView.C b/src/frontends/qt3/QtView.C index f8bc508b1c..ba6e975304 100644 --- a/src/frontends/qt3/QtView.C +++ b/src/frontends/qt3/QtView.C @@ -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(); diff --git a/src/frontends/qt3/QtView.h b/src/frontends/qt3/QtView.h index ca0dc1e97d..6ab6423385 100644 --- a/src/frontends/qt3/QtView.h +++ b/src/frontends/qt3/QtView.h @@ -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_; diff --git a/src/frontends/qt4/Alert_pimpl.C b/src/frontends/qt4/Alert_pimpl.C index 7c669d551a..63a44ba2a5 100644 --- a/src/frontends/qt4/Alert_pimpl.C +++ b/src/frontends/qt4/Alert_pimpl.C @@ -29,17 +29,17 @@ #include 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 const -askForText_pimpl(string const & msg, string const & dflt) +pair 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(true, fromqstr(text)); + return make_pair(true, qstring_to_ucs4(text)); else - return make_pair(false, string()); + return make_pair(false, docstring()); } diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 8eba2f2545..b54e9a5334 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -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(); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index e72ad8bde7..43535538ff 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -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_; diff --git a/src/frontends/qt4/QChanges.C b/src/frontends/qt4/QChanges.C index dc75ee7ab2..79e0375703 100644 --- a/src/frontends/qt4/QChanges.C +++ b/src/frontends/qt4/QChanges.C @@ -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)); } diff --git a/src/frontends/qt4/QDocumentDialog.C b/src/frontends/qt4/QDocumentDialog.C index d5a604878e..164e76d8af 100644 --- a/src/frontends/qt4/QDocumentDialog.C +++ b/src/frontends/qt4/QDocumentDialog.C @@ -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)); } } diff --git a/src/frontends/qt4/QPrefsDialog.C b/src/frontends/qt4/QPrefsDialog.C index 959bbbacfe..733018cb10 100644 --- a/src/frontends/qt4/QPrefsDialog.C +++ b/src/frontends/qt4/QPrefsDialog.C @@ -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; } diff --git a/src/frontends/qt4/QSpellchecker.C b/src/frontends/qt4/QSpellchecker.C index 7c82cff162..45cb47676b 100644 --- a/src/frontends/qt4/QSpellchecker.C +++ b/src/frontends/qt4/QSpellchecker.C @@ -46,8 +46,8 @@ void QSpellchecker::build_dialog() void QSpellchecker::update_contents() { - if (isVisible() || controller().exitEarly()) { - controller().check(); + if (isVisible()) { +// controller().check(); } } diff --git a/src/frontends/qt4/qt_helpers.C b/src/frontends/qt4/qt_helpers.C index e8a8dda7f9..44fcf98e2f 100644 --- a/src/frontends/qt4/qt_helpers.C +++ b/src/frontends/qt4/qt_helpers.C @@ -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; diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index 01d1196540..d1e8de8935 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -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 diff --git a/src/frontends/qt4/validators.C b/src/frontends/qt4/validators.C index e0676ea264..74ccd42746 100644 --- a/src/frontends/qt4/validators.C +++ b/src/frontends/qt4/validators.C @@ -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; diff --git a/src/gettext.C b/src/gettext.C index ec1ea63252..6c79a241d1 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -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() diff --git a/src/graphics/GraphicsCacheItem.C b/src/graphics/GraphicsCacheItem.C index 476b28521b..3bb95a1f08 100644 --- a/src/graphics/GraphicsCacheItem.C +++ b/src/graphics/GraphicsCacheItem.C @@ -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); diff --git a/src/importer.C b/src/importer.C index 7f627f092b..d363a74ebe 100644 --- a/src/importer.C +++ b/src/importer.C @@ -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; } diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 7bcb327aef..91647a2a04 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -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){ diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index cd247819dd..4a34e60fdc 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -113,7 +113,8 @@ void InsetCaption::setLabel(LCursor & cur) const num = convert(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))); } } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 8f1eca6016..11ed1d86d1 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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); } diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index bdc7312244..a16280888f 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -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; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index e3ad40f403..c7a48dad46 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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; } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 72fd3b0156..0c4722c87d 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index faebec58b3..f2725b6a55 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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()) { diff --git a/src/ispell.C b/src/ispell.C index 124a1d4bf1..85742611f2 100644 --- a/src/ispell.C +++ b/src/ispell.C @@ -32,6 +32,8 @@ # include #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_; } diff --git a/src/ispell.h b/src/ispell.h index e33d848cb7..44efb4aa14 100644 --- a/src/ispell.h +++ b/src/ispell.h @@ -15,6 +15,8 @@ #include "SpellBase.h" +#include "support/docstring.h" + #include #include @@ -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 child_; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 6f8f68012a..df07a86090 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -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.")); } diff --git a/src/lyx_main.C b/src/lyx_main.C index 16d231b244..a01b2c7f47 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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()); diff --git a/src/lyxfind.C b/src/lyxfind.C index ce3d59b028..8ca56cbc4a 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -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(replace_count); - str += lyx::to_utf8(_(" strings have been replaced.")); + docstring str = convert(replace_count); + str += _(" strings have been replaced."); // emit message signal. buf->message(str); } diff --git a/src/lyxfont.C b/src/lyxfont.C index fe884cdc2f..cebd9954fb 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -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(), ", "); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 8233460c38..6a48ac6d9f 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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 " - " ")); + setErrorMessage(lyx::from_utf8(N_("Syntax: set-color " + " "))); 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; } diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 7a1e63370d..7fa82bb621 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -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) diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 9007d31c44..415402b4cc 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -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; } diff --git a/src/lyxrc.C b/src/lyxrc.C index 6d3d101b33..9ac9724453 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -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: diff --git a/src/lyxserver.C b/src/lyxserver.C index 16243172a9..7a05e818ff 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -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 diff --git a/src/lyxsocket.C b/src/lyxsocket.C index 5755bb6dcf..4af70e10b2 100644 --- a/src/lyxsocket.C +++ b/src/lyxsocket.C @@ -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 { diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 040cad9649..7eae766cff 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -31,6 +31,7 @@ namespace fs = boost::filesystem; #include +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; diff --git a/src/lyxtextclasslist.C b/src/lyxtextclasslist.C index 11e08c0883..8c23fd2dc2 100644 --- a/src/lyxtextclasslist.C +++ b/src/lyxtextclasslist.C @@ -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; diff --git a/src/lyxvc.C b/src/lyxvc.C index b7de1af96f..49b69ad94c 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -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 tmp = - Alert::askForText(lyx::to_utf8(_("LyX VC: Initial description")), - lyx::to_utf8(_("(no initial description)"))); + pair 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 tmp = Alert::askForText(lyx::to_utf8(_("LyX VC: Log Message"))); + pair 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(); diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index e4e69d4a79..d183f2a25c 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -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_))); } diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index 16d5ba463a..4bcc0ab343 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -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; } diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index c77519dad2..60ad0d57b2 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -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; } } diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index af651cb33f..c4dbf502de 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -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' diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 111026f693..9d6380d0fa 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -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 diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index c8f9453361..3607a35d1b 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -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_)); } diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index cc6e751754..b45b3e27bd 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -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: diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index abf0b4ec62..e1349cc926 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -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; } diff --git a/src/mathed/math_substackinset.C b/src/mathed/math_substackinset.C index 97a7ee3825..3d1e48a8fa 100644 --- a/src/mathed/math_substackinset.C +++ b/src/mathed/math_substackinset.C @@ -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; } diff --git a/src/output.C b/src/output.C index 11e96aee6a..e45640df36 100644 --- a/src/output.C +++ b/src/output.C @@ -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; diff --git a/src/pspell.C b/src/pspell.C index f7122650ba..62d65e9546 100644 --- a/src/pspell.C +++ b/src/pspell.C @@ -24,6 +24,8 @@ extern "C" { #include +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; diff --git a/src/pspell.h b/src/pspell.h index d645aacad3..f5e6b23950 100644 --- a/src/pspell.h +++ b/src/pspell.h @@ -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 diff --git a/src/support/filetools.C b/src/support/filetools.C index 5143809092..ca5584211e 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -955,7 +955,7 @@ string const unzipFile(string const & zipped_file, string const & unzipped_file) } -string const makeDisplayPath(string const & path, unsigned int threshold) +docstring const makeDisplayPath(string const & path, unsigned int threshold) { string str = path; string const home = package().home_dir(); @@ -965,7 +965,7 @@ string const makeDisplayPath(string const & path, unsigned int threshold) str = subst(str, home, "~"); if (str.length() <= threshold) - return os::external_path(str); + return lyx::from_utf8(os::external_path(str)); string const prefix = ".../"; string temp; @@ -986,7 +986,7 @@ string const makeDisplayPath(string const & path, unsigned int threshold) str = head + "..." + tail; } - return os::external_path(prefix + str); + return lyx::from_utf8(os::external_path(prefix + str)); } diff --git a/src/support/filetools.h b/src/support/filetools.h index 5cda2f75dd..96fd707b5a 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -12,6 +12,8 @@ #ifndef LYX_FILETOOL_H #define LYX_FILETOOL_H +#include "support/docstring.h" + #include #include #include @@ -202,7 +204,7 @@ std::string const makeAbsPath(std::string const & RelPath = std::string(), /** Creates a nice compact path for displaying. The parameter threshold, if given, specifies the maximal length of the path. */ -std::string const +lyx::docstring const makeDisplayPath(std::string const & path, unsigned int threshold = 1000); /** Makes relative path out of absolute path. diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 895a2e934b..f9fc6cbd00 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -32,6 +32,8 @@ #include #include +using lyx::docstring; + using std::transform; using std::string; using std::vector; @@ -676,179 +678,178 @@ docstring const internalLineEnding(docstring const & str) #if USE_BOOST_FORMAT template<> -string bformat(string const & fmt, int arg1) +docstring bformat(docstring const & fmt, int arg1) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1).str(); } template<> -string bformat(string const & fmt, long arg1) +docstring bformat(docstring const & fmt, long arg1) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1).str(); } template<> -string bformat(string const & fmt, unsigned int arg1) +docstring bformat(docstring const & fmt, unsigned int arg1) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1).str(); } template<> -string bformat(string const & fmt, string arg1) +docstring bformat(docstring const & fmt, docstring arg1) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1).str(); +} + + +docstring bformat(docstring const & fmt, char * arg1) +{ + return (boost::basic_format(fmt) % arg1).str(); } template<> -string bformat(string const & fmt, char * arg1) +docstring bformat(docstring const & fmt, int arg1, int arg2) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1 % arg2).str(); } template<> -string bformat(string const & fmt, int arg1, int arg2) +docstring bformat(docstring const & fmt, docstring arg1, docstring arg2) { - return (boost::format(fmt) % arg1 % arg2).str(); + return (boost::basic_format(fmt) % arg1 % arg2).str(); } template<> -string bformat(string const & fmt, string arg1, string arg2) +docstring bformat(docstring const & fmt, char const * arg1, docstring arg2) { - return (boost::format(fmt) % arg1 % arg2).str(); + return (boost::basic_format(fmt) % arg1 % arg2).str(); } template<> -string bformat(string const & fmt, char const * arg1, string arg2) +docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3) { - return (boost::format(fmt) % arg1 % arg2).str(); + return (boost::basic_format(fmt) % arg1 % arg2 % arg3).str(); } template<> -string bformat(string const & fmt, string arg1, string arg2, string arg3) +docstring bformat(docstring const & fmt, + docstring arg1, docstring arg2, docstring arg3, docstring arg4) { - return (boost::format(fmt) % arg1 % arg2 % arg3).str(); -} - - -template<> -string bformat(string const & fmt, - string arg1, string arg2, string arg3, string arg4) -{ - return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4).str(); + return (boost::basic_format(fmt) % arg1 % arg2 % arg3 % arg4).str(); } #else template<> -string bformat(string const & fmt, int arg1) +docstring bformat(docstring const & fmt, int arg1) { - BOOST_ASSERT(contains(fmt, "%1$d")); - string const str = subst(fmt, "%1$d", convert(arg1)); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d"))); + docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert(arg1)); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, long arg1) +docstring bformat(docstring const & fmt, long arg1) { - BOOST_ASSERT(contains(fmt, "%1$d")); - string const str = subst(fmt, "%1$d", convert(arg1)); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d"))); + docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert(arg1)); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, unsigned int arg1) +docstring bformat(docstring const & fmt, unsigned int arg1) { - BOOST_ASSERT(contains(fmt, "%1$d")); - string const str = subst(fmt, "%1$d", convert(arg1)); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d"))); + docstring const str = subst(fmt, lyx::from_ascii("%1$d"), convert(arg1)); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, string arg1) +docstring bformat(docstring const & fmt, docstring arg1) { - BOOST_ASSERT(contains(fmt, "%1$s")); - string const str = subst(fmt, "%1$s", arg1); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + docstring const str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, char * arg1) +docstring bformat(docstring const & fmt, char * arg1) { - BOOST_ASSERT(contains(fmt, "%1$s")); - string const str = subst(fmt, "%1$s", arg1); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + docstring const str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, string arg1, string arg2) +docstring bformat(docstring const & fmt, docstring arg1, docstring arg2) { - BOOST_ASSERT(contains(fmt, "%1$s")); - BOOST_ASSERT(contains(fmt, "%2$s")); - string str = subst(fmt, "%1$s", arg1); - str = subst(str, "%2$s", arg2); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s"))); + docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + str = subst(str, lyx::from_ascii("%2$s"), arg2); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, char const * arg1, string arg2) +docstring bformat(docstring const & fmt, char const * arg1, docstring arg2) { - BOOST_ASSERT(contains(fmt, "%1$s")); - BOOST_ASSERT(contains(fmt, "%2$s")); - string str = subst(fmt, "%1$s", arg1); - str = subst(fmt, "%2$s", arg2); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s"))); + docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + str = subst(fmt, lyx::from_ascii("%2$s"), arg2); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, int arg1, int arg2) +docstring bformat(docstring const & fmt, int arg1, int arg2) { - BOOST_ASSERT(contains(fmt, "%1$d")); - BOOST_ASSERT(contains(fmt, "%2$d")); - string str = subst(fmt, "%1$d", convert(arg1)); - str = subst(str, "%2$d", convert(arg2)); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$d"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$d"))); + docstring str = subst(fmt, lyx::from_ascii("%1$d"), convert(arg1)); + str = subst(str, lyx::from_ascii("%2$d"), convert(arg2)); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, string arg1, string arg2, string arg3) +docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3) { - BOOST_ASSERT(contains(fmt, "%1$s")); - BOOST_ASSERT(contains(fmt, "%2$s")); - BOOST_ASSERT(contains(fmt, "%3$s")); - string str = subst(fmt, "%1$s", arg1); - str = subst(str, "%2$s", arg2); - str = subst(str, "%3$s", arg3); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%3$s"))); + docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + str = subst(str, lyx::from_ascii("%2$s"), arg2); + str = subst(str, lyx::from_ascii("%3$s"), arg3); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } template<> -string bformat(string const & fmt, - string arg1, string arg2, string arg3, string arg4) +docstring bformat(docstring const & fmt, + docstring arg1, docstring arg2, docstring arg3, docstring arg4) { - BOOST_ASSERT(contains(fmt, "%1$s")); - BOOST_ASSERT(contains(fmt, "%2$s")); - BOOST_ASSERT(contains(fmt, "%3$s")); - BOOST_ASSERT(contains(fmt, "%4$s")); - string str = subst(fmt, "%1$s", arg1); - str = subst(str, "%2$s", arg2); - str = subst(str, "%3$s", arg3); - str = subst(str, "%4$s", arg4); - return subst(str, "%%", "%"); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%1$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%2$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%3$s"))); + BOOST_ASSERT(contains(fmt, lyx::from_ascii("%4$s"))); + docstring str = subst(fmt, lyx::from_ascii("%1$s"), arg1); + str = subst(str, lyx::from_ascii("%2$s"), arg2); + str = subst(str, lyx::from_ascii("%3$s"), arg3); + str = subst(str, lyx::from_ascii("%4$s"), arg4); + return subst(str, lyx::from_ascii("%%"), lyx::from_ascii("%")); } #endif diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 705f5bbfad..36b556a81c 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -140,16 +140,16 @@ int tokenPos(std::string const & a, char delim, std::string const & tok); std::string const subst(std::string const & a, char oldchar, char newchar); /// Substitute all \a oldchar with \a newchar -docstring const subst(docstring const & a, - char_type oldchar, char_type newchar); +lyx::docstring const subst(docstring const & a, + lyx::char_type oldchar, lyx::char_type newchar); /// substitutes all instances of \a oldstr with \a newstr std::string const subst(std::string const & a, std::string const & oldstr, std::string const & newstr); /// substitutes all instances of \a oldstr with \a newstr -docstring const subst(docstring const & a, - docstring const & oldstr, docstring const & newstr); +lyx::docstring const subst(lyx::docstring const & a, + lyx::docstring const & oldstr, lyx::docstring const & newstr); /** Trims characters off the end and beginning of a string. \code @@ -205,10 +205,10 @@ std::string const getStringFromVector(std::vector const & vec, int findToken(char const * const str[], std::string const & search_token); /// Convert internal line endings to line endings as expected by the OS -docstring const externalLineEnding(docstring const & str); +lyx::docstring const externalLineEnding(lyx::docstring const & str); /// Convert line endings in any formnat to internal line endings -docstring const internalLineEnding(docstring const & str); +lyx::docstring const internalLineEnding(lyx::docstring const & str); #ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES @@ -216,45 +216,45 @@ docstring const internalLineEnding(docstring const & str); #include template -string bformat(string const & fmt, Arg1 arg1) +lyx::docstring bformat(lyx::docstring const & fmt, Arg1 arg1) { - return (boost::format(fmt) % arg1).str(); + return (boost::basic_format(fmt) % arg1).str(); } template -string bformat(string const & fmt, Arg1 arg1, Arg2 arg2) +lyx::docstring bformat(lyx::docstring const & fmt, Arg1 arg1, Arg2 arg2) { - return (boost::format(fmt) % arg1 % arg2).str(); + return (boost::basic_format(fmt) % arg1 % arg2).str(); } template -string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3) +lyx::docstring bformat(lyx::docstring const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3) { - return (boost::format(fmt) % arg1 % arg2 % arg3).str(); + return (boost::basic_format(fmt) % arg1 % arg2 % arg3).str(); } template -string bformat(string const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) +lyx::docstring bformat(lyx::docstring const & fmt, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) { - return (boost::format(fmt) % arg1 % arg2 % arg3 % arg4).str(); + return (boost::basic_format(fmt) % arg1 % arg2 % arg3 % arg4).str(); } #else template -std::string bformat(std::string const & fmt, Arg1); +lyx::docstring bformat(lyx::docstring const & fmt, Arg1); template -std::string bformat(std::string const & fmt, Arg1, Arg2); +lyx::docstring bformat(lyx::docstring const & fmt, Arg1, Arg2); template -std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3); +lyx::docstring bformat(lyx::docstring const & fmt, Arg1, Arg2, Arg3); template -std::string bformat(std::string const & fmt, Arg1, Arg2, Arg3, Arg4); +lyx::docstring bformat(lyx::docstring const & fmt, Arg1, Arg2, Arg3, Arg4); #endif diff --git a/src/support/package.C.in b/src/support/package.C.in index 690943974b..f666e6eceb 100644 --- a/src/support/package.C.in +++ b/src/support/package.C.in @@ -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; } diff --git a/src/text.C b/src/text.C index 56f2d4da0e..589ad2e982 100644 --- a/src/text.C +++ b/src/text.C @@ -190,9 +190,9 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, bool hasLayout = tclass.hasLayout(layoutname); if (!hasLayout) { - errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown layout")), - bformat(lyx::to_utf8(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n")), - layoutname, tclass.name()), par.id(), 0, par.size())); + errorList.push_back(ErrorItem(_("Unknown layout"), + bformat(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n"), + lyx::from_utf8(layoutname), lyx::from_utf8(tclass.name())), par.id(), 0, par.size())); layoutname = tclass.defaultLayoutName(); } @@ -221,8 +221,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, par.insertInset(par.size(), inset, font, change); else { lex.eatLine(); - string line = lex.getString(); - errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown Inset")), line, + docstring line = lyx::from_utf8(lex.getString()); + errorList.push_back(ErrorItem(_("Unknown Inset"), line, par.id(), 0, par.size())); } } else if (token == "\\family") { @@ -339,8 +339,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, lyx::time_type ct; is >> aid >> ct; if (aid >= bp.author_map.size()) { - errorList.push_back(ErrorItem(lyx::to_utf8(_("Change tracking error")), - bformat(lyx::to_utf8(_("Unknown author index for insertion: %1$d\n")), aid), + errorList.push_back(ErrorItem(_("Change tracking error"), + bformat(_("Unknown author index for insertion: %1$d\n"), aid), par.id(), 0, par.size())); change = Change(Change::UNCHANGED); @@ -353,8 +353,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, lyx::time_type ct; is >> aid >> ct; if (aid >= bp.author_map.size()) { - errorList.push_back(ErrorItem(lyx::to_utf8(_("Change tracking error")), - bformat(lyx::to_utf8(_("Unknown author index for deletion: %1$d\n")), aid), + errorList.push_back(ErrorItem(_("Change tracking error"), + bformat(_("Unknown author index for deletion: %1$d\n"), aid), par.id(), 0, par.size())); change = Change(Change::UNCHANGED); @@ -362,8 +362,9 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, change = Change(Change::DELETED, bp.author_map[aid], ct); } else { lex.eatLine(); - errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown token")), - bformat(lyx::to_utf8(_("Unknown token: %1$s %2$s\n")), token, lex.getString()), + errorList.push_back(ErrorItem(_("Unknown token"), + bformat(_("Unknown token: %1$s %2$s\n"), lyx::from_utf8(token), + lyx::from_utf8(lex.getString())), par.id(), 0, par.size())); } } @@ -1240,8 +1241,8 @@ void LyXText::insertChar(LCursor & cur, char_type c) if (cur.pos() == 0) { static bool sent_space_message = false; if (!sent_space_message) { - cur.message(lyx::to_utf8(_("You cannot insert a space at the " - "beginning of a paragraph. Please read the Tutorial."))); + cur.message(_("You cannot insert a space at the " + "beginning of a paragraph. Please read the Tutorial.")); sent_space_message = true; } return; @@ -1252,8 +1253,8 @@ void LyXText::insertChar(LCursor & cur, char_type c) && par.lookupChange(cur.pos() - 1) != Change::DELETED) { static bool sent_space_message = false; if (!sent_space_message) { - cur.message(lyx::to_utf8(_("You cannot type two spaces this way. " - "Please read the Tutorial."))); + cur.message(_("You cannot type two spaces this way. " + "Please read the Tutorial.")); sent_space_message = true; } return; @@ -2390,14 +2391,14 @@ string LyXText::currentState(LCursor & cur) // avoid lyx::to_utf8(_(...)) re-entrance problem string const s = font.stateText(&buf.params()); - os << bformat(lyx::to_utf8(_("Font: %1$s")), s); + os << lyx::to_utf8(bformat(_("Font: %1$s"), lyx::from_utf8(s))); - // os << bformat(lyx::to_utf8(_("Font: %1$s")), font.stateText(&buf.params)); + // os << lyx::to_utf8(bformat(_("Font: %1$s"), font.stateText(&buf.params))); // The paragraph depth int depth = cur.paragraph().getDepth(); if (depth > 0) - os << bformat(lyx::to_utf8(_(", Depth: %1$d")), depth); + os << lyx::to_utf8(bformat(_(", Depth: %1$d"), depth)); // The paragraph spacing, but only if different from // buffer spacing. diff --git a/src/text2.C b/src/text2.C index ea0abd304b..3ea699d4ab 100644 --- a/src/text2.C +++ b/src/text2.C @@ -554,8 +554,8 @@ void LyXText::toggleFree(LCursor & cur, LyXFont const & font, bool toggleall) // If the mask is completely neutral, tell user if (font == LyXFont(LyXFont::ALL_IGNORE)) { // Could only happen with user style - cur.message(lyx::to_utf8(_("No font change defined. " - "Use Character under the Layout menu to define font change."))); + cur.message(_("No font change defined. " + "Use Character under the Layout menu to define font change.")); return; } @@ -596,9 +596,9 @@ string LyXText::getStringToIndex(LCursor const & cur) selectWord(tmpcur, lyx::PREVIOUS_WORD); if (!tmpcur.selection()) - cur.message(lyx::to_utf8(_("Nothing to index!"))); + cur.message(_("Nothing to index!")); else if (tmpcur.selBegin().pit() != tmpcur.selEnd().pit()) - cur.message(lyx::to_utf8(_("Cannot index more than one paragraph!"))); + cur.message(_("Cannot index more than one paragraph!")); else idxstring = tmpcur.selectionAsString(false); } diff --git a/src/text3.C b/src/text3.C index b50a4253ec..5ad1714872 100644 --- a/src/text3.C +++ b/src/text3.C @@ -182,7 +182,7 @@ namespace { } else cur.insert(new MathMacroTemplate(is)); } - cur.message(N_("Math editor mode")); + cur.message(lyx::from_utf8(N_("Math editor mode"))); } } // namespace anon @@ -760,7 +760,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) break; case LFUN_PASTE: - cur.message(lyx::to_utf8(_("Paste"))); + cur.message(_("Paste")); lyx::cap::replaceSelection(cur); if (isStrUnsignedInt(lyx::to_utf8(cmd.argument()))) pasteSelection(cur, bv->buffer()->errorList("Paste"), @@ -776,17 +776,18 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_CUT: cutSelection(cur, true, true); - cur.message(lyx::to_utf8(_("Cut"))); + cur.message(_("Cut")); break; case LFUN_COPY: copySelection(cur); - cur.message(lyx::to_utf8(_("Copy"))); + cur.message(_("Copy")); break; case LFUN_SERVER_GET_XY: - cur.message(convert(cursorX(cur.top(), cur.boundary())) + ' ' - + convert(cursorY(cur.top(), cur.boundary()))); + cur.message(lyx::from_utf8( + convert(cursorX(cur.top(), cur.boundary())) + ' ' + + convert(cursorY(cur.top(), cur.boundary())))); break; case LFUN_SERVER_SET_XY: { @@ -804,15 +805,15 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_SERVER_GET_FONT: if (current_font.shape() == LyXFont::ITALIC_SHAPE) - cur.message("E"); + cur.message(lyx::from_utf8("E")); else if (current_font.shape() == LyXFont::SMALLCAPS_SHAPE) - cur.message("N"); + cur.message(lyx::from_utf8("N")); else - cur.message("0"); + cur.message(lyx::from_utf8("0")); break; case LFUN_SERVER_GET_LAYOUT: - cur.message(cur.paragraph().layout()->name()); + cur.message(lyx::from_utf8(cur.paragraph().layout()->name())); break; case LFUN_LAYOUT: { @@ -825,7 +826,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) // function list/array with information about what // functions needs arguments and their type. if (cmd.argument().empty()) { - cur.errorMessage(lyx::to_utf8(_("LyX function 'layout' needs an argument."))); + cur.errorMessage(_("LyX function 'layout' needs an argument.")); break; } @@ -843,8 +844,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) } if (!hasLayout) { - cur.errorMessage(string(N_("Layout ")) + lyx::to_utf8(cmd.argument()) + - N_(" not known")); + cur.errorMessage(lyx::from_utf8(N_("Layout ")) + cmd.argument() + + lyx::from_utf8(N_(" not known"))); break; } @@ -1198,7 +1199,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_MATH_MACRO: if (cmd.argument().empty()) - cur.errorMessage(N_("Missing argument")); + cur.errorMessage(lyx::from_utf8(N_("Missing argument"))); else { string s = lyx::to_utf8(cmd.argument()); string const s1 = token(s, ' ', 1); @@ -1303,7 +1304,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_FONT_FREE_APPLY: toggleAndShow(cur, this, freefont, toggleall); - cur.message(lyx::to_utf8(_("Character set"))); + cur.message(_("Character set")); break; // Set the freefont using the contents of \param data dispatched from @@ -1315,7 +1316,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) freefont = font; toggleall = toggle; toggleAndShow(cur, this, freefont, toggleall); - cur.message(lyx::to_utf8(_("Character set"))); + cur.message(_("Character set")); } break; } @@ -1448,7 +1449,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) params.align(), params.labelWidthString(), params.noindent()); - cur.message(lyx::to_utf8(_("Paragraph layout set"))); + cur.message(_("Paragraph layout set")); break; }