Skip to content

Commit

Permalink
ORCID fix: provide no element if the locale is not in ISO 639-1
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Dec 6, 2024
1 parent 947744c commit 1cd9dfa
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions classes/orcid/PKPOrcidWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ private function build(): array
],
'publication-date' => $this->buildOrcidPublicationDate($this->publication),
'url' => $publicationUrl,
'language-code' => LocaleConversion::getIso1FromLocale($publicationLocale),
'contributors' => [
'contributor' => $this->buildOrcidContributors($this->authors, $this->context, $this->publication)
]
];

$iso1PublicationLocale = LocaleConversion::getIso1FromLocale($publicationLocale);
if ($iso1PublicationLocale) {
$orcidWork['language-code'] = $iso1PublicationLocale;
}

$bibtexCitation = $this->getBibtexCitation($submission);
if (!empty($bibtexCitation)) {
$orcidWork['citation'] = [
Expand All @@ -106,7 +110,10 @@ private function build(): array

foreach ($this->publication->getData('title') as $locale => $title) {
if ($locale !== $publicationLocale) {
$orcidWork['title']['translated-title'] = ['value' => $title, 'language-code' => LocaleConversion::getIso1FromLocale($locale)];
$iso1Locale = LocaleConversion::getIso1FromLocale($locale);
if ($iso1Locale) {
$orcidWork['title']['translated-title'] = ['value' => $title, 'language-code' => $iso1Locale];
}
}
}

Expand Down Expand Up @@ -293,8 +300,6 @@ private function buildOrcidContributors(array $authors, Context $context, Public
/**
* Gets any non-DOI PubId external IDs, e.g. for Issues
*
* @param PubIdPlugin $plugin
* @return array
*/
protected function getAppPubIdExternalIds(PubIdPlugin $plugin): array
{
Expand All @@ -304,7 +309,6 @@ protected function getAppPubIdExternalIds(PubIdPlugin $plugin): array
/**
* Gets any app-specific DOI external IDs, e.g. for Issues
*
* @return array
*/
protected function getAppDoiExternalIds(): array
{
Expand All @@ -314,8 +318,6 @@ protected function getAppDoiExternalIds(): array
/**
* Uses the CitationStyleLanguage plugin to get bibtex citation if possible
*
* @param Submission $submission
* @return string
*/
protected function getBibtexCitation(Submission $submission): string
{
Expand Down

0 comments on commit 1cd9dfa

Please sign in to comment.