]> git.lyx.org Git - features.git/commitdiff
Use document language when exporting citations to LyXHTML (fixes #7732).
authorJulien Rioux <jrioux@lyx.org>
Thu, 8 Mar 2012 17:03:50 +0000 (18:03 +0100)
committerJulien Rioux <jrioux@lyx.org>
Thu, 10 Jan 2013 11:34:06 +0000 (12:34 +0100)
src/BiblioInfo.cpp
src/BiblioInfo.h
src/insets/InsetBibtex.cpp
src/insets/InsetCitation.cpp
status.20x

index f3fe83fdd0d5f23a57e1cfb3259cbadce6652b90..cd707c115137404b1cbf72aee97fbce3e1508ac2 100644 (file)
@@ -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<docstring> 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<docstring> const BiblioInfo::getNumericalStrings(
        if (empty())
                return vector<docstring>();
 
-       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<docstring>();
 
@@ -782,8 +786,9 @@ vector<docstring> const BiblioInfo::getAuthorYearStrings(
        if (empty())
                return vector<docstring>();
 
-       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<docstring>();
 
index acfc0222dfae4a324e52a08a49039bbb345dc73c..29d910c2d0756c57d5aad82cb8f2be990d604aa7 100644 (file)
@@ -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<docstring> 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.
index 0e80857288c05992f385fd454092d74ba2c49962..16dbfb2d8587a7bb727efee22ad209c1290a5f0f 100644 (file)
@@ -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;
                }
index 6f9035c5b9f4606d07f8323428d7beb0587cbef7..d3f9271c6a75d8851c1a98b3baf7fe7afb91398e 100644 (file)
@@ -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/<before field>
 
        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<docstring>::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())
index dff640494477e341c1a66df086f498302597ff5d..73c0aef56efb684575402241332dd2af7b2d6019 100644 (file)
@@ -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