{}
-docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style, string lang) const
+docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style) const
{
if (!is_bibtex_) {
docstring const opt = label();
return shortauthor;
}
- if (authors.size() == 2)
- return bformat(translateIfPossible(from_ascii("%1$s and %2$s"), lang),
+ if (authors.size() == 2 && authors[1] != "others")
+ return bformat(from_ascii("%1$s and %2$s"),
familyName(authors[0]), familyName(authors[1]));
- if (authors.size() > 2)
- return bformat(translateIfPossible(from_ascii("%1$s et al."), lang),
+ if (authors.size() >= 2)
+ return bformat(from_ascii("%1$s et al."),
familyName(authors[0]));
return familyName(authors[0]);
}
+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_)
static int max_passes = 5000;
docstring ret; // return value
string key;
- string lang = buf.params().language->code();
bool scanning_key = false;
bool scanning_rich = false;
// so we replace the key with its value, which may be empty
if (key[0] == '!') {
// macro
- // FIXME: instead of passing the buf, just past the macros
- // FIXME: and the language code
string const val =
buf.params().documentClass().getCiteMacro(engine_type, key);
fmt = val + fmt.substr(1);
string const val =
buf.params().documentClass().getCiteMacro(engine_type, key);
docstring const trans =
- translateIfPossible(from_utf8(val), lang);
+ translateIfPossible(from_utf8(val), buf.params().language->code());
ret += trans;
} else {
docstring const val =
- getValueForKey(key, before, after, dialog, xref, lang);
+ getValueForKey(key, buf, before, after, dialog, xref);
if (!scanning_rich)
ret += from_ascii("{!<span class=\"bib-" + key + "\">!}");
ret += val;
return _("ERROR!");
fmt = newfmt;
docstring const val =
- getValueForKey(optkey, before, after, dialog, xref, lang);
+ getValueForKey(optkey, buf, before, after, dialog, xref);
if (optkey == "next" && next)
ret += from_utf8(ifpart); // without expansion
else if (!val.empty())
}
-docstring BibTeXInfo::getValueForKey(string const & key,
+docstring BibTeXInfo::getValueForKey(string const & key, Buffer const & buf,
docstring const & before, docstring const & after, docstring const & dialog,
- BibTeXInfo const * const xref, string lang) const
+ BibTeXInfo const * const xref) const
{
docstring ret = operator[](key);
if (ret.empty() && xref)
return label_;
else if (key == "abbrvauthor")
// Special key to provide abbreviated author names.
- return getAbbreviatedAuthor(false, lang);
+ return 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.
- return getAbbreviatedAuthor(true, lang);
+ return getAbbreviatedAuthor(buf, true);
else if (key == "shorttitle") {
// When shorttitle is not defined, jurabib uses for `article'
// and `periodical' entries the form `journal volume [year]'
}
-docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key, string lang) const
+docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key, Buffer const & buf) const
{
BiblioInfo::const_iterator it = find(key);
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
- return data.getAbbreviatedAuthor(false, lang);
+ return data.getAbbreviatedAuthor(buf, false);
}
}
-docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier, string lang) const
+docstring const BiblioInfo::getYear(docstring const & key, bool use_modifier) const
{
BiblioInfo::const_iterator it = find(key);
if (it == end())
docstring const xref = data.getXRef();
if (xref.empty())
// no luck
- return translateIfPossible(from_ascii("No year"), lang);
+ return docstring();
BiblioInfo::const_iterator const xrefit = find(xref);
if (xrefit == end())
// no luck again
- return translateIfPossible(from_ascii("No year"), lang);
+ return docstring();
BibTeXInfo const & xref_data = xrefit->second;
year = xref_data.getYear();
}
}
+docstring const BiblioInfo::getYear(docstring const & key, Buffer const & buf, bool use_modifier) const
+{
+ docstring const year = getYear(key, use_modifier);
+ if (year.empty())
+ return buf.B_("No year");
+ return year;
+}
+
+
docstring const BiblioInfo::getInfo(docstring const & key,
Buffer const & buf, bool richtext) const
{
BibTeXInfo(bool ib) : is_bibtex_(ib) {}
/// constructor that sets the entryType
BibTeXInfo(docstring const & key, docstring const & type);
- /// \return the short form of an authorlist
- docstring const getAbbreviatedAuthor(bool jurabib_style = false, std::string lang = "en") const;
+ /// \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;
///
docstring const getYear() const;
///
/// like operator[], except, if the field is empty, it will attempt
/// to get the data from xref BibTeXInfo object, which would normally
/// be the one referenced in the crossref field.
- docstring getValueForKey(std::string const & key,
+ docstring getValueForKey(std::string const & key, Buffer const & buf,
docstring const & before, docstring const & after, docstring const & dialog,
- BibTeXInfo const * const xref = 0, std::string lang = "en") const;
+ BibTeXInfo const * const xref = 0) const;
/// replace %keys% in a format string with their values
/// called from getInfo()
/// format strings may contain:
/// \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, std::string lang = "en") const;
+ docstring const getAbbreviatedAuthor(docstring const & key, Buffer const & buf) 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, std::string lang = "en") const;
+ bool use_modifier = false) 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.
+ /// If no year is found, \return "No year" translated to the buffer
+ /// language.
+ docstring const getYear(docstring const & key, Buffer const & buf,
+ bool use_modifier = false) const;
///
docstring const getCiteNumber(docstring const & key) const;
/// \return formatted BibTeX data associated with a given key.