diff --git a/OAIMetadataFormat_JATS.php b/OAIMetadataFormat_JATS.php index 6ddbb78..564b956 100644 --- a/OAIMetadataFormat_JATS.php +++ b/OAIMetadataFormat_JATS.php @@ -32,6 +32,7 @@ use PKP\core\DataObject; use PKP\oai\OAIMetadataFormat; use PKP\db\DAORegistry; +use PKP\i18n\LocaleConversion; use PKP\submission\Genre; use PKP\submissionFile\SubmissionFile; use PKP\plugins\PluginRegistry; @@ -195,7 +196,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) $publication = $article->getCurrentPublication(); $articleNode = $xpath->query('//article')->item(0); - $articleNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $article->getData('locale'))); + $articleNode->setAttribute('xml:lang', LocaleConversion::toBcp47($article->getData('locale'))); $articleNode->setAttribute('dtd-version', '1.1'); $articleNode->setAttribute('specific-use', 'eps-0.1'); $articleNode->setAttribute('xmlns', 'https://jats.nlm.nih.gov/publishing/1.1/'); @@ -303,7 +304,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) $titleNode = $this->_addChildInOrder($articleMetaNode, $doc->createElement('issue-title')); $titleText = $doc->createTextNode($title); $titleNode->appendChild($titleText); - $titleNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $locale)); + $titleNode->setAttribute('xml:lang', LocaleConversion::toBcp47($locale)); } } @@ -313,7 +314,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) $titleGroupNode->removeChild($titleGroupNode->firstChild); } $titleNode = $titleGroupNode->appendChild($doc->createElement('article-title')); - $titleNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $article->getData('locale'))); + $titleNode->setAttribute('xml:lang', LocaleConversion::toBcp47($article->getData('locale'))); $articleTitleHtml = $doc->createDocumentFragment(); $articleTitleHtml->appendXML( @@ -331,7 +332,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) $subtitleHtml->appendXML($this->mapHtmlTagsForTitle($subtitle)); $subtitleNode = $titleGroupNode->appendChild($doc->createElement('subtitle')); - $subtitleNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $article->getData('locale'))); + $subtitleNode->setAttribute('xml:lang', LocaleConversion::toBcp47($article->getData('locale'))); $subtitleNode->appendChild($subtitleHtml); } @@ -345,7 +346,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) } $transTitleGroupNode = $titleGroupNode->appendChild($doc->createElement('trans-title-group')); - $transTitleGroupNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $locale)); + $transTitleGroupNode->setAttribute('xml:lang', LocaleConversion::toBcp47($locale)); $titleNode = $transTitleGroupNode->appendChild($doc->createElement('trans-title')); $titleHtml = $doc->createDocumentFragment(); @@ -380,7 +381,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) } $kwdGroupNode = $this->_addChildInOrder($articleMetaNode, $doc->createElement('kwd-group')); - $kwdGroupNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $locale)); + $kwdGroupNode->setAttribute('xml:lang', LocaleConversion::toBcp47($locale)); $kwdGroupNode->appendChild($doc->createElement('title'))->appendChild($doc->createTextNode(__('article.subject', [], $locale))); foreach ($keywords as $keyword) { $kwdGroupNode->appendChild($doc->createElement('kwd'))->appendChild($doc->createTextNode($keyword)); @@ -411,7 +412,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) $abstractDoc->loadXML(($isPrimary ? '' : '') . $purifier->purify($abstract) . ($isPrimary ? '' : '')); $abstractNode = $this->_addChildInOrder($articleMetaNode, $doc->importNode($abstractDoc->documentElement, true)); if (!$isPrimary) { - $abstractNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $locale)); + $abstractNode->setAttribute('xml:lang', LocaleConversion::toBcp47($locale)); } } @@ -489,7 +490,7 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) } $subjGroupNode = $articleCategoriesNode->appendChild($doc->createElement('subj-group')); $subjGroupNode->setAttribute('subj-group-type', 'heading'); - $subjGroupNode->setAttribute('xml:lang', str_replace(['_', '@'], '-', $locale)); + $subjGroupNode->setAttribute('xml:lang', LocaleConversion::toBcp47($locale)); $subjectNode = $subjGroupNode->appendChild($doc->createElement('subject')); $subjectNode->appendChild($doc->createTextNode($title)); }