diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index f3fe83fdd0..cd707c1151 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -212,7 +212,7 @@ BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type) {} -docstring const BibTeXInfo::getAbbreviatedAuthor() const +docstring const BibTeXInfo::getAbbreviatedAuthor(string lang) const { if (!is_bibtex_) { docstring const opt = label(); @@ -244,11 +244,12 @@ docstring const BibTeXInfo::getAbbreviatedAuthor() const getVectorFromString(author, from_ascii(" and ")); if (authors.size() == 2) - return bformat(_("%1$s and %2$s"), + return bformat(translateIfPossible(from_ascii("%1$s and %2$s"), lang), familyName(authors[0]), familyName(authors[1])); if (authors.size() > 2) - return bformat(_("%1$s et al."), familyName(authors[0])); + return bformat(translateIfPossible(from_ascii("%1$s et al."), lang), + familyName(authors[0])); return familyName(authors[0]); } @@ -634,13 +635,13 @@ vector const BiblioInfo::getEntries() const } -docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key) const +docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key, string lang) const { BiblioInfo::const_iterator it = find(key); if (it == end()) return docstring(); BibTeXInfo const & data = it->second; - return data.getAbbreviatedAuthor(); + return data.getAbbreviatedAuthor(lang); } @@ -654,7 +655,7 @@ docstring const BiblioInfo::getCiteNumber(docstring const & key) const } -docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier) const +docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier, string lang) const { BiblioInfo::const_iterator it = find(key); if (it == end()) @@ -665,10 +666,12 @@ docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier) co // let's try the crossref docstring const xref = data.getXRef(); if (xref.empty()) - return _("No year"); // no luck + // no luck + return translateIfPossible(from_ascii("No year"), lang); BiblioInfo::const_iterator const xrefit = find(xref); if (xrefit == end()) - return _("No year"); // no luck again + // no luck again + return translateIfPossible(from_ascii("No year"), lang); BibTeXInfo const & xref_data = xrefit->second; year = xref_data.getYear(); } @@ -723,8 +726,9 @@ vector const BiblioInfo::getNumericalStrings( if (empty()) return vector(); - docstring const author = getAbbreviatedAuthor(key); - docstring const year = getYear(key); + string const lang = buf.params().language->code(); + docstring const author = getAbbreviatedAuthor(key, lang); + docstring const year = getYear(key, true, lang); if (author.empty() || year.empty()) return vector(); @@ -782,8 +786,9 @@ vector const BiblioInfo::getAuthorYearStrings( if (empty()) return vector(); - docstring const author = getAbbreviatedAuthor(key); - docstring const year = getYear(key); + string const lang = buf.params().language->code(); + docstring const author = getAbbreviatedAuthor(key, lang); + docstring const year = getYear(key, true, lang); if (author.empty() || year.empty()) return vector(); diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index acfc0222df..29d910c2d0 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -54,7 +54,7 @@ public: /// constructor that sets the entryType BibTeXInfo(docstring const & key, docstring const & type); /// \return the short form of an authorlist - docstring const getAbbreviatedAuthor() const; + docstring const getAbbreviatedAuthor(std::string lang = "en") const; /// docstring const getYear() const; /// @@ -162,14 +162,14 @@ public: /// \return a sorted vector of BibTeX entry types in use std::vector const getEntries() const; /// \return the short form of an authorlist - docstring const getAbbreviatedAuthor(docstring const & key) const; + docstring const getAbbreviatedAuthor(docstring const & key, std::string lang = "en") const; /// \return the year from the bibtex data record for \param key /// if \param use_modifier is true, then we will also append any /// modifier for this entry (e.g., 1998b). /// Note that this will get the year from the crossref if it's /// not present in the record itself. docstring const getYear(docstring const & key, - bool use_modifier = false) const; + bool use_modifier = false, std::string lang = "en") const; /// docstring const getCiteNumber(docstring const & key) const; /// \return formatted BibTeX data associated with a given key. diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 0e80857288..16dbfb2d85 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -958,10 +958,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const if (numbers) citekey = entry.citeNumber(); else { - docstring const auth = entry.getAbbreviatedAuthor(); + docstring const auth = entry.getAbbreviatedAuthor(l->code()); // we do it this way so as to access the xref, if necessary // note that this also gives us the modifier - docstring const year = bibinfo.getYear(*vit, true); + docstring const year = bibinfo.getYear(*vit, true, l->code()); if (!auth.empty() && !year.empty()) citekey = auth + ' ' + year; } diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index 6f9035c5b9..d3f9271c6a 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -21,6 +21,7 @@ #include "DispatchResult.h" #include "FuncCode.h" #include "FuncRequest.h" +#include "Language.h" #include "LaTeXFeatures.h" #include "output_xhtml.h" #include "ParIterator.h" @@ -259,6 +260,7 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const // CITE: author/ CiteEngine const engine = buffer().params().citeEngine(); + Language const * lang = buffer().params().language; // We don't currently use the full or forceUCase fields. string cite_type = asValidLatexCommand(getCmdName(), engine); if (cite_type[0] == 'C') @@ -321,8 +323,8 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const vector::const_iterator end = keys.end(); for (; it != end; ++it) { // get the bibdata corresponding to the key - docstring const author = biblist.getAbbreviatedAuthor(*it); - docstring const year = biblist.getYear(*it, for_xhtml); + docstring const author = biblist.getAbbreviatedAuthor(*it, lang->code()); + docstring const year = biblist.getYear(*it, for_xhtml, lang->code()); docstring const citenum = for_xhtml ? biblist.getCiteNumber(*it) : *it; if (author.empty() || year.empty()) diff --git a/status.20x b/status.20x index dff6404944..73c0aef56e 100644 --- a/status.20x +++ b/status.20x @@ -96,6 +96,8 @@ What's new - Fix the output of LyXHTML bibliography with richtext (bug 8486). +- Use document language when exporting citations to LyXHTML (bug 7732). + * USER INTERFACE