Skip to content

Commit

Permalink
adapt language distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Dec 5, 2024
1 parent 790a6e3 commit bcadf0a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
12 changes: 6 additions & 6 deletions cypress/tests/integration/Z_MonographViewDCMetadata.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('Monograph View Metadata - DC Plugin', function() {
]
},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeMetadata
.find(element => element.locale == 'fr_CA')
Expand All @@ -212,7 +212,7 @@ describe('Monograph View Metadata - DC Plugin', function() {
]
},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeTitles.fr_CA.abstract
]
Expand All @@ -223,7 +223,7 @@ describe('Monograph View Metadata - DC Plugin', function() {
element: 'DC.Title.Alternative',
values: [
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeTitles.fr_CA.prefix + ' ' + submission.localeTitles.fr_CA.title + ': ' + submission.localeTitles.fr_CA.subtitle
]
Expand All @@ -246,7 +246,7 @@ describe('Monograph View Metadata - DC Plugin', function() {

},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeMetadata
.find(element => element.locale == 'fr_CA')
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('Monograph View Metadata - DC Plugin', function() {
)
},
{
locale: 'fr',
locale: 'fr-CA',
contents: submission.localeMetadata
.find(element => element.locale == 'fr_CA')
.manyValues
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('Monograph View Metadata - DC Plugin', function() {
withScheme: [
{
element: 'DC.Language',
scheme: 'ISO639-1',
scheme: 'rfc5646',
content: 'en'
},
{
Expand Down
33 changes: 16 additions & 17 deletions plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use APP\core\Application;
use APP\template\TemplateManager;
use PKP\i18n\LocaleConversion;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;

Expand Down Expand Up @@ -84,15 +83,15 @@ public function monographView($hookName, $args)
if ($supportingAgencies = $publication->getData('supportingAgencies')) {
foreach ($supportingAgencies as $locale => $localeSupportingAgencies) {
foreach ($localeSupportingAgencies as $i => $supportingAgency) {
$templateMgr->addHeader('dublinCoreSponsor' . $locale . $i++, '<meta name="DC.Contributor.Sponsor" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($supportingAgency) . '"/>');
$templateMgr->addHeader('dublinCoreSponsor' . $locale . $i++, '<meta name="DC.Contributor.Sponsor" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($supportingAgency) . '"/>');
}
}
}

if ($coverages = $publication->getData('coverage')) {
foreach ($coverages as $locale => $coverage) {
if ($coverage != '') {
$templateMgr->addHeader('dublinCoreCoverage' . $locale, '<meta name="DC.Coverage" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($coverage)) . '"/>');
$templateMgr->addHeader('dublinCoreCoverage' . $locale, '<meta name="DC.Coverage" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($coverage)) . '"/>');
}
}
}
Expand All @@ -118,7 +117,7 @@ public function monographView($hookName, $args)
$abstracts = $isChapterRequest ? $chapter->getData('abstract') : $publication->getData('abstract');
foreach ($abstracts ?: [] as $locale => $abstract) {
if ($abstract != '') {
$templateMgr->addHeader('dublinCoreAbstract' . $locale, '<meta name="DC.Description" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
$templateMgr->addHeader('dublinCoreAbstract' . $locale, '<meta name="DC.Description" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
}
}

Expand All @@ -136,7 +135,7 @@ public function monographView($hookName, $args)

$templateMgr->addHeader('dublinCoreUri', '<meta name="DC.Identifier.URI" content="' . $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'catalog', 'book', [$submissionBestId], urlLocaleForPage: '') . '"/>');

$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="ISO639-1" content="' . substr($publicationLocale, 0, 2) . '"/>');
$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="rfc5646" content="' . str_replace(['_', '@'], '-', $publicationLocale) . '"/>');

if (($copyrightHolder = $publication->getData('copyrightHolder', $publicationLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) {
$templateMgr->addHeader('dublinCoreCopyright', '<meta name="DC.Rights" content="' . htmlspecialchars(__('submission.copyrightStatement', ['copyrightHolder' => $copyrightHolder, 'copyrightYear' => $copyrightYear])) . '"/>');
Expand All @@ -151,14 +150,14 @@ public function monographView($hookName, $args)
if ($subjects = $publication->getData('subjects')) {
foreach ($subjects as $locale => $localeSubjects) {
foreach ($localeSubjects as $i => $subject) {
$templateMgr->addHeader('dublinCoreSubject' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
$templateMgr->addHeader('dublinCoreSubject' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
}
}
}
if ($keywords = $publication->getData('keywords')) {
foreach ($keywords as $locale => $localeKeywords) {
foreach ($localeKeywords as $i => $keyword) {
$templateMgr->addHeader('dublinCoreKeyword' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
$templateMgr->addHeader('dublinCoreKeyword' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
}
}
}
Expand All @@ -168,15 +167,15 @@ public function monographView($hookName, $args)
$titles = $isChapterRequest ? $chapter->getFullTitles() : $publication->getFullTitles();
foreach ($titles as $locale => $altTitle) {
if ($title != '' && $locale != $publicationLocale) {
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
}
}

$templateMgr->addHeader('dublinCoreType', '<meta name="DC.Type" content="Text.Book"/>');
if ($types = $publication->getData('type')) {
foreach ($types as $locale => $type) {
if ($type != '') {
$templateMgr->addHeader('dublinCoreType' . $locale, '<meta name="DC.Type" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($type)) . '"/>');
$templateMgr->addHeader('dublinCoreType' . $locale, '<meta name="DC.Type" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($type)) . '"/>');
}
}
}
Expand Down Expand Up @@ -221,15 +220,15 @@ public function monographFileView($hookName, $args)
if ($supportingAgencies = $publication->getData('supportingAgencies')) {
foreach ($supportingAgencies as $locale => $localeSupportingAgencies) {
foreach ($localeSupportingAgencies as $i => $supportingAgency) {
$templateMgr->addHeader('dublinCoreSponsor' . $locale . $i++, '<meta name="DC.Contributor.Sponsor" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($supportingAgency) . '"/>');
$templateMgr->addHeader('dublinCoreSponsor' . $locale . $i++, '<meta name="DC.Contributor.Sponsor" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($supportingAgency) . '"/>');
}
}
}

if ($coverages = $publication->getData('coverage')) {
foreach ($coverages as $locale => $coverage) {
if ($coverage != '') {
$templateMgr->addHeader('dublinCoreCoverage' . $locale, '<meta name="DC.Coverage" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($coverage)) . '"/>');
$templateMgr->addHeader('dublinCoreCoverage' . $locale, '<meta name="DC.Coverage" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($coverage)) . '"/>');
}
}
}
Expand All @@ -255,7 +254,7 @@ public function monographFileView($hookName, $args)
$abstracts = $chapter ? $chapter->getData('abstract') : $publication->getData('abstract');
foreach ($abstracts ?: [] as $locale => $abstract) {
if ($abstract != '') {
$templateMgr->addHeader('dublinCoreAbstract' . $locale, '<meta name="DC.Description" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
$templateMgr->addHeader('dublinCoreAbstract' . $locale, '<meta name="DC.Description" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
}
}

Expand All @@ -279,7 +278,7 @@ public function monographFileView($hookName, $args)

$templateMgr->addHeader('dublinCoreUri', '<meta name="DC.Identifier.URI" content="' . $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'catalog', 'book', [$submissionBestId, $publicationFormat->getId(), $submissionFile->getId()], urlLocaleForPage: '') . '"/>');

$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="ISO639-1" content="' . substr($publicationLocale, 0, 2) . '"/>');
$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="ISO639-1" content="' . str_replace(['_', '@'], '-', $publicationLocale) . '"/>');

if (($copyrightHolder = $publication->getData('copyrightHolder', $publicationLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) {
$templateMgr->addHeader('dublinCoreCopyright', '<meta name="DC.Rights" content="' . htmlspecialchars(__('submission.copyrightStatement', ['copyrightHolder' => $copyrightHolder, 'copyrightYear' => $copyrightYear])) . '"/>');
Expand All @@ -298,14 +297,14 @@ public function monographFileView($hookName, $args)
if ($subjects = $publication->getData('subjects')) {
foreach ($subjects as $locale => $localeSubjects) {
foreach ($localeSubjects as $i => $subject) {
$templateMgr->addHeader('dublinCoreSubject' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
$templateMgr->addHeader('dublinCoreSubject' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
}
}
}
if ($keywords = $publication->getData('keywords')) {
foreach ($keywords as $locale => $localeKeywords) {
foreach ($localeKeywords as $i => $keyword) {
$templateMgr->addHeader('dublinCoreKeyword' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
$templateMgr->addHeader('dublinCoreKeyword' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
}
}
}
Expand All @@ -316,15 +315,15 @@ public function monographFileView($hookName, $args)
$titles = $chapter ? $chapter->getFullTitles() : $publication->getFullTitles();
foreach ($titles as $locale => $altTitle) {
if ($title != '' && $locale != $publicationLocale) {
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
}
}

$templateMgr->addHeader('dublinCoreType', '<meta name="DC.Type" content="Text.Chapter"/>');
if ($types = $publication->getData('type')) {
foreach ($types as $locale => $type) {
if ($type != '') {
$templateMgr->addHeader('dublinCoreType' . $locale, '<meta name="DC.Type" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($type)) . '"/>');
$templateMgr->addHeader('dublinCoreType' . $locale, '<meta name="DC.Type" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars(strip_tags($type)) . '"/>');
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/generic/googleScholar/GoogleScholarPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function monographView($hookName, $args)
$templateMgr->addHeader('googleScholarTitle', '<meta name="citation_title" content="' . htmlspecialchars($title) . '"/>');

// Language
$templateMgr->addHeader('googleScholarLanguage', '<meta name="citation_language" content="' . htmlspecialchars(substr($publicationLocale, 0, 2)) . '"/>');
$templateMgr->addHeader('googleScholarLanguage', '<meta name="citation_language" content="' . htmlspecialchars(str_replace(['_', '@'], '-', $publicationLocale)) . '"/>');

// Publication date
$datePublished = $isChapterRequest
Expand All @@ -115,7 +115,7 @@ public function monographView($hookName, $args)
// Abstract
$abstract = $isChapterRequest ? $chapter->getLocalizedData('abstract', $publicationLocale) : $publication->getLocalizedData('abstract', $publicationLocale);
if ($abstract != '') {
$templateMgr->addHeader('googleScholarAbstract', '<meta name="citation_abstract" xml:lang="' . htmlspecialchars(substr($publicationLocale, 0, 2)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
$templateMgr->addHeader('googleScholarAbstract', '<meta name="citation_abstract" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $publicationLocale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
}

// Publication DOI
Expand All @@ -127,7 +127,7 @@ public function monographView($hookName, $args)
if ($subjects = $publication->getData('subjects')) {
foreach ($subjects as $locale => $localeSubjects) {
foreach ($localeSubjects as $i => $subject) {
$templateMgr->addHeader('googleScholarSubject' . $i++, '<meta name="citation_keywords" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
$templateMgr->addHeader('googleScholarSubject' . $i++, '<meta name="citation_keywords" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($subject) . '"/>');
}
}
}
Expand All @@ -136,7 +136,7 @@ public function monographView($hookName, $args)
if ($keywords = $publication->getData('keywords')) {
foreach ($keywords as $locale => $localeKeywords) {
foreach ($localeKeywords as $i => $keyword) {
$templateMgr->addHeader('googleScholarKeyword' . $i++, '<meta name="citation_keywords" xml:lang="' . htmlspecialchars(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
$templateMgr->addHeader('googleScholarKeyword' . $i++, '<meta name="citation_keywords" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
}
}
}
Expand Down

0 comments on commit bcadf0a

Please sign in to comment.