mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
The way this was previously, it had to fail if the GUI language
was not English: We return the the abbreviated author "One and Two", but translated to the GUI language; then we search that for " and " in order to pull the authors apart again. I've just replaced the distinct routines with a single one that handles both cases, depending upon whether a Buffer is provided as one argument.
This commit is contained in:
parent
d5633f17e5
commit
fb84ccd9fb
@ -255,7 +255,8 @@ BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style) const
|
docstring const BibTeXInfo::getAbbreviatedAuthor(
|
||||||
|
Buffer const * buf, bool jurabib_style) const
|
||||||
{
|
{
|
||||||
if (!is_bibtex_) {
|
if (!is_bibtex_) {
|
||||||
docstring const opt = label();
|
docstring const opt = label();
|
||||||
@ -296,29 +297,20 @@ docstring const BibTeXInfo::getAbbreviatedAuthor(bool jurabib_style) const
|
|||||||
|
|
||||||
docstring retval = familyName(authors[0]);
|
docstring retval = familyName(authors[0]);
|
||||||
|
|
||||||
if (authors.size() == 2 && authors[1] != "others")
|
if (authors.size() == 2 && authors[1] != "others") {
|
||||||
retval = bformat(from_ascii("%1$s and %2$s"),
|
docstring const dformat = buf ?
|
||||||
familyName(authors[0]), familyName(authors[1]));
|
buf->B_("%1$s and %2$s") : from_ascii("%1$s and %2$s");
|
||||||
else if (authors.size() >= 2)
|
retval = bformat(dformat, familyName(authors[0]), familyName(authors[1]));
|
||||||
retval = bformat(from_ascii("%1$s et al."),
|
} else if (authors.size() >= 2) {
|
||||||
familyName(authors[0]));
|
// 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
|
||||||
return convertLaTeXCommands(retval);
|
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -719,12 +711,12 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
|
|||||||
ret = cite_number_;
|
ret = cite_number_;
|
||||||
else if (key == "abbrvauthor")
|
else if (key == "abbrvauthor")
|
||||||
// Special key to provide abbreviated author names.
|
// Special key to provide abbreviated author names.
|
||||||
ret = getAbbreviatedAuthor(buf, false);
|
ret = getAbbreviatedAuthor(&buf, false);
|
||||||
else if (key == "shortauthor")
|
else if (key == "shortauthor")
|
||||||
// When shortauthor is not defined, jurabib automatically
|
// When shortauthor is not defined, jurabib automatically
|
||||||
// provides jurabib-style abbreviated author names. We do
|
// provides jurabib-style abbreviated author names. We do
|
||||||
// this as well.
|
// this as well.
|
||||||
ret = getAbbreviatedAuthor(buf, true);
|
ret = getAbbreviatedAuthor(&buf, true);
|
||||||
else if (key == "shorttitle") {
|
else if (key == "shorttitle") {
|
||||||
// When shorttitle is not defined, jurabib uses for `article'
|
// When shorttitle is not defined, jurabib uses for `article'
|
||||||
// and `periodical' entries the form `journal volume [year]'
|
// and `periodical' entries the form `journal volume [year]'
|
||||||
@ -821,7 +813,7 @@ docstring const BiblioInfo::getAbbreviatedAuthor(docstring const & key, Buffer c
|
|||||||
if (it == end())
|
if (it == end())
|
||||||
return docstring();
|
return docstring();
|
||||||
BibTeXInfo const & data = it->second;
|
BibTeXInfo const & data = it->second;
|
||||||
return data.getAbbreviatedAuthor(buf, false);
|
return data.getAbbreviatedAuthor(&buf, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1097,7 +1089,7 @@ void BiblioInfo::makeCitationLabels(Buffer const & buf)
|
|||||||
if (numbers) {
|
if (numbers) {
|
||||||
entry.label(entry.citeNumber());
|
entry.label(entry.citeNumber());
|
||||||
} else {
|
} 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
|
// we do it this way so as to access the xref, if necessary
|
||||||
// note that this also gives us the modifier
|
// note that this also gives us the modifier
|
||||||
docstring const year = getYear(*it, buf, true);
|
docstring const year = getYear(*it, buf, true);
|
||||||
|
@ -52,10 +52,10 @@ public:
|
|||||||
/// constructor that sets the entryType
|
/// constructor that sets the entryType
|
||||||
BibTeXInfo(docstring const & key, docstring const & type);
|
BibTeXInfo(docstring const & key, docstring const & type);
|
||||||
/// \return the short form of an authorlist, used for sorting
|
/// \return the short form of an authorlist, used for sorting
|
||||||
docstring const getAbbreviatedAuthor(bool jurabib_style = false) const;
|
/// this will be translated to the UI language if buf is null
|
||||||
/// \return the short form of an authorlist, translated to the
|
/// otherwise, it will be translated to the buffer language.
|
||||||
/// buffer language.
|
docstring const getAbbreviatedAuthor(
|
||||||
docstring const getAbbreviatedAuthor(Buffer const & buf, bool jurabib_style = false) const;
|
Buffer const * buf = 0, bool jurabib_style = false) const;
|
||||||
///
|
///
|
||||||
docstring const getYear() const;
|
docstring const getYear() const;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user