Skip to content
Snippets Groups Projects
Commit 4cdda83e authored by Juha Luoma's avatar Juha Luoma Committed by Robert Lange
Browse files

Citation improvements (#1417)

- Include all authors, not just first primary author
- Translate 'and'
- Correct 'et al.' punctuation
parent 50b12df3
Branches
Tags
No related merge requests found
...@@ -59,6 +59,7 @@ alphabrowselink_html = "Browse entries by %%index%% starting from <a href="%%url ...@@ -59,6 +59,7 @@ alphabrowselink_html = "Browse entries by %%index%% starting from <a href="%%url
An error has occurred = "An error has occurred" An error has occurred = "An error has occurred"
An error occurred during execution; please try again later. = "An error occurred during execution; please try again later." An error occurred during execution; please try again later. = "An error occurred during execution; please try again later."
AND = "AND" AND = "AND"
and = "and"
anonymous_tags = "Anonymous Tags" anonymous_tags = "Anonymous Tags"
APA Citation = "APA Citation" APA Citation = "APA Citation"
applied_filter = "Applied Filter" applied_filter = "Applied Filter"
......
...@@ -58,6 +58,7 @@ alphabrowselink_html = "Selaa %%index%%-indeksiä alkaen kohdasta <a href="%%url ...@@ -58,6 +58,7 @@ alphabrowselink_html = "Selaa %%index%%-indeksiä alkaen kohdasta <a href="%%url
An error has occurred = "Tapahtui virhe" An error has occurred = "Tapahtui virhe"
An error occurred during execution; please try again later. = "Virhe toimintoa suoritettaessa. Yritä myöhemmin uudelleen." An error occurred during execution; please try again later. = "Virhe toimintoa suoritettaessa. Yritä myöhemmin uudelleen."
AND = "JA" AND = "JA"
and = "ja"
anonymous_tags = "Tuntemattomien tagit" anonymous_tags = "Tuntemattomien tagit"
APA Citation = "APA-viite" APA Citation = "APA-viite"
applied_filter = "Käytetty suodatus" applied_filter = "Käytetty suodatus"
......
...@@ -58,6 +58,7 @@ alphabrowselink_html = "Bläddra efter %%index%% från <a href="%%url%%">%%from% ...@@ -58,6 +58,7 @@ alphabrowselink_html = "Bläddra efter %%index%% från <a href="%%url%%">%%from%
An error has occurred = "Det har uppstått ett fel" An error has occurred = "Det har uppstått ett fel"
An error occurred during execution; please try again later. = "Utförandet misslyckades. Försök på nytt efter en stund." An error occurred during execution; please try again later. = "Utförandet misslyckades. Försök på nytt efter en stund."
AND = "OCH" AND = "OCH"
and = "och"
anonymous_tags = "Anonyma taggar" anonymous_tags = "Anonyma taggar"
APA Citation = "APA-referens" APA Citation = "APA-referens"
applied_filter = "Filter i bruk" applied_filter = "Filter i bruk"
......
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
* @category VuFind * @category VuFind
* @package View_Helpers * @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
namespace VuFind\View\Helper\Root; namespace VuFind\View\Helper\Root;
use VuFind\Date\DateException; use VuFind\Date\DateException;
use VuFind\I18n\Translator\TranslatorAwareInterface;
/** /**
* Citation view helper * Citation view helper
...@@ -35,11 +37,15 @@ use VuFind\Date\DateException; ...@@ -35,11 +37,15 @@ use VuFind\Date\DateException;
* @category VuFind * @category VuFind
* @package View_Helpers * @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
class Citation extends \Zend\View\Helper\AbstractHelper class Citation extends \Zend\View\Helper\AbstractHelper
implements TranslatorAwareInterface
{ {
use \VuFind\I18n\Translator\TranslatorAwareTrait;
/** /**
* Citation details * Citation details
* *
...@@ -82,16 +88,12 @@ class Citation extends \Zend\View\Helper\AbstractHelper ...@@ -82,16 +88,12 @@ class Citation extends \Zend\View\Helper\AbstractHelper
public function __invoke($driver) public function __invoke($driver)
{ {
// Build author list: // Build author list:
$authors = []; $authors = (array)$driver->tryMethod('getPrimaryAuthors');
$primary = $driver->tryMethod('getPrimaryAuthor'); if (empty($authors)) {
if (empty($primary)) { $authors = (array)$driver->tryMethod('getCorporateAuthors');
$primary = $driver->tryMethod('getCorporateAuthor');
}
if (!empty($primary)) {
$authors[] = $primary;
} }
$secondary = $driver->tryMethod('getSecondaryAuthors'); $secondary = (array)$driver->tryMethod('getSecondaryAuthors');
if (is_array($secondary) && !empty($secondary)) { if (!empty($secondary)) {
$authors = array_unique(array_merge($authors, $secondary)); $authors = array_unique(array_merge($authors, $secondary));
} }
...@@ -702,12 +704,12 @@ class Citation extends \Zend\View\Helper\AbstractHelper ...@@ -702,12 +704,12 @@ class Citation extends \Zend\View\Helper\AbstractHelper
$i = 0; $i = 0;
if (count($this->details['authors']) > $etAlThreshold) { if (count($this->details['authors']) > $etAlThreshold) {
$author = $this->details['authors'][0]; $author = $this->details['authors'][0];
$authorStr = $this->cleanNameDates($author) . ', et al'; $authorStr = $this->cleanNameDates($author) . ', et al.';
} else { } else {
foreach ($this->details['authors'] as $author) { foreach ($this->details['authors'] as $author) {
if (($i + 1 == count($this->details['authors'])) && ($i > 0)) { if (($i + 1 == count($this->details['authors'])) && ($i > 0)) {
// Last // Last
$authorStr .= ', and ' . $authorStr .= ', ' . $this->translate('and') . ' ' .
$this->reverseName($this->stripPunctuation($author)); $this->reverseName($this->stripPunctuation($author));
} elseif ($i > 0) { } elseif ($i > 0) {
$authorStr .= ', ' . $authorStr .= ', ' .
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment