Skip to content

Commit

Permalink
Merge pull request #53 from bozana/9707
Browse files Browse the repository at this point in the history
pkp/pkp-lib#9707 rename locales, adapt language distribution
  • Loading branch information
bozana authored Dec 11, 2024
2 parents 0a13f2f + 8bbf7ca commit 298444f
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions filter/ArticleCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use DOMElement;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\i18n\LocaleConversion;
use PKP\submission\GenreDAO;

class ArticleCrossrefXmlFilter extends IssueCrossrefXmlFilter
Expand Down Expand Up @@ -108,7 +107,7 @@ public function createJournalArticleNode($doc, $submission)

$journalArticleNode = $doc->createElementNS($deployment->getNamespace(), 'journal_article');
$journalArticleNode->setAttribute('publication_type', 'full_text');
$journalArticleNode->setAttribute('language', LocaleConversion::getIso1FromLocale($locale));
$journalArticleNode->setAttribute('language', \Locale::getPrimaryLanguage($locale));

// title
$titleLanguages = array_keys($publication->getTitles());
Expand Down Expand Up @@ -156,7 +155,7 @@ public function createJournalArticleNode($doc, $submission)

// Check if both givenName and familyName is set for the submission language.
if (!empty($familyNames[$locale]) && !empty($givenNames[$locale])) {
$personNameNode->setAttribute('language', LocaleConversion::getIso1FromLocale($locale));
$personNameNode->setAttribute('language', \Locale::getPrimaryLanguage($locale));
$personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'given_name', htmlspecialchars(ucfirst($givenNames[$locale]), ENT_COMPAT, 'UTF-8')));
$personNameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'surname', htmlspecialchars(ucfirst($familyNames[$locale]), ENT_COMPAT, 'UTF-8')));

Expand All @@ -174,7 +173,7 @@ public function createJournalArticleNode($doc, $submission)
}

$nameNode = $doc->createElementNS($deployment->getNamespace(), 'name');
$nameNode->setAttribute('language', LocaleConversion::getIso1FromLocale($otherLocal));
$nameNode->setAttribute('language', \Locale::getPrimaryLanguage($otherLocal));

$nameNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'surname', htmlspecialchars(ucfirst($familyName), ENT_COMPAT, 'UTF-8')));
if (isset($givenNames[$otherLocal]) && !empty($givenNames[$otherLocal])) {
Expand All @@ -201,7 +200,7 @@ public function createJournalArticleNode($doc, $submission)
$abstracts = $publication->getData('abstract') ?: [];
foreach($abstracts as $lang => $abstract) {
$abstractNode = $doc->createElementNS($deployment->getJATSNamespace(), 'jats:abstract');
$abstractNode->setAttributeNS($deployment->getXMLNamespace(), 'xml:lang', LocaleConversion::getIso1FromLocale($lang));
$abstractNode->setAttributeNS($deployment->getXMLNamespace(), 'xml:lang', str_replace(['_', '@'], '-', $lang));
$abstractNode->appendChild($node = $doc->createElementNS($deployment->getJATSNamespace(), 'jats:p', htmlspecialchars(html_entity_decode(strip_tags($abstract), ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8')));
$journalArticleNode->appendChild($abstractNode);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 298444f

Please sign in to comment.