{}
-docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style) const
+docstring const BibTeXInfo::getAbbreviatedAuthor(
+ Buffer const * buf, bool jurabib_style) const
{
if (!is_bibtex_) {
docstring const opt = label();
docstring retval = familyName(authors[0]);
- if (authors.size() == 2 && authors[1] != "others")
- retval = bformat(from_ascii("%1$s and %2$s"),
- familyName(authors[0]), familyName(authors[1]));
- else if (authors.size() >= 2)
- retval = bformat(from_ascii("%1$s et al."),
- familyName(authors[0]));
+ if (authors.size() == 2 && authors[1] != "others") {
+ docstring const dformat = buf ?
+ buf->B_("%1$s and %2$s") : from_ascii("%1$s and %2$s");
+ retval = bformat(dformat, familyName(authors[0]), familyName(authors[1]));
+ } else if (authors.size() >= 2) {
+ // we get here either if the author list is longer than two names
+ // or if the second 'name' is "others". we do the same thing either
+ // way.
+ docstring const dformat = buf ?
+ buf->B_("%1$s et al.") : from_ascii("%1$s et al.");
+ retval = bformat(dformat, familyName(authors[0]));
+ }
return convertLaTeXCommands(retval);
}
-docstring const BibTeXInfo::getAbbreviatedAuthor(Buffer const & buf, bool jurabib_style) const
-{
- docstring const author = getAbbreviatedAuthor(jurabib_style);
- if (!is_bibtex_)
- return author;
- vector<docstring> const authors = getVectorFromString(author, from_ascii(" and "));
- if (authors.size() == 2)
- return bformat(buf.B_("%1$s and %2$s"), authors[0], authors[1]);
- docstring::size_type const idx = author.rfind(from_ascii(" et al."));
- if (idx != docstring::npos)
- return bformat(buf.B_("%1$s et al."), author.substr(0, idx));
- return author;
-}
-
-
docstring const BibTeXInfo::getYear() const
{
if (is_bibtex_)
ret = cite_number_;
else if (key == "abbrvauthor")
// Special key to provide abbreviated author names.
- ret = getAbbreviatedAuthor(buf, false);
+ ret = getAbbreviatedAuthor(&buf, false);
else if (key == "shortauthor")
// When shortauthor is not defined, jurabib automatically
// provides jurabib-style abbreviated author names. We do
// this as well.
- ret = getAbbreviatedAuthor(buf, true);
+ ret = getAbbreviatedAuthor(&buf, true);
else if (key == "shorttitle") {
// When shorttitle is not defined, jurabib uses for `article'
// and `periodical' entries the form `journal volume [year]'
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
- return data.getAbbreviatedAuthor(buf, false);
+ return data.getAbbreviatedAuthor(&buf, false);
}
if (numbers) {
entry.label(entry.citeNumber());
} else {
- docstring const auth = entry.getAbbreviatedAuthor(buf, false);
+ docstring const auth = entry.getAbbreviatedAuthor(&buf, false);
// we do it this way so as to access the xref, if necessary
// note that this also gives us the modifier
docstring const year = getYear(*it, buf, true);
/// constructor that sets the entryType
BibTeXInfo(docstring const & key, docstring const & type);
/// \return the short form of an authorlist, used for sorting
- docstring const getAbbreviatedAuthor(bool jurabib_style = false) const;
- /// \return the short form of an authorlist, translated to the
- /// buffer language.
- docstring const getAbbreviatedAuthor(Buffer const & buf, bool jurabib_style = false) const;
+ /// this will be translated to the UI language if buf is null
+ /// otherwise, it will be translated to the buffer language.
+ docstring const getAbbreviatedAuthor(
+ Buffer const * buf = 0, bool jurabib_style = false) const;
///
docstring const getYear() const;
///