Skip to content

Commit

Permalink
Merge pull request #4495 from bozana/9707
Browse files Browse the repository at this point in the history
pkp/pkp-lib#9707 use weblate locales for ui
  • Loading branch information
bozana authored Dec 11, 2024
2 parents fb759ca + 96f424e commit 0522b5c
Show file tree
Hide file tree
Showing 295 changed files with 45 additions and 39 deletions.
7 changes: 5 additions & 2 deletions classes/orcid/OrcidReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function build(): array
$orcidReview['review-url'] = ['value' => $publicationUrl];
$orcidReview['subject-type'] = 'journal-article';
$orcidReview['subject-name'] = [
'title' => ['value' => $this->submission->getCurrentPublication()->getLocalizedData('title') ?? '']
'title' => ['value' => $this->submission->getCurrentPublication()->getLocalizedTitle($submissionLocale) ?? '']
];

if (!empty($currentPublication->getDoi())) {
Expand All @@ -125,7 +125,10 @@ private function build(): array
$allTitles = $currentPublication->getData('title');
foreach ($allTitles as $locale => $title) {
if ($locale !== $submissionLocale) {
$orcidReview['subject-name']['translated-title'] = ['value' => $title, 'language-code' => LocaleConversion::getIso1FromLocale($locale)];
$iso1Locale = LocaleConversion::getIso1FromLocale($locale);
if ($iso1Locale) {
$orcidReview['subject-name']['translated-title'] = ['value' => $title, 'language-code' => $iso1Locale];
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/articleGalleys/form/ArticleGalleyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct($request, $submission, $publication, $articleGalley
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));

// Ensure a locale is provided and valid
$locales = $submission->getPublicationLanguages($request->getJournal()->getSupportedSubmissionMetadataLocales(), $articleGalley?->getLanguages());
$locales = $submission->getPublicationLanguages($request->getJournal()->getSupportedSubmissionLocales(), $articleGalley?->getLanguages());
$this->addCheck(
new \PKP\form\validation\FormValidatorCustom(
$this,
Expand Down Expand Up @@ -92,7 +92,7 @@ public function fetch($request, $template = null, $display = false)
]);
}

$supportedLocales = $request->getContext()->getSupportedSubmissionMetadataLocaleNames() + $this->_submission->getPublicationLanguageNames() + ($this->_articleGalley?->getLanguageNames() ?? []);
$supportedLocales = $request->getContext()->getSupportedSubmissionLocaleNames() + $this->_submission->getPublicationLanguageNames() + ($this->_articleGalley?->getLanguageNames() ?? []);
ksort($supportedLocales);

$templateMgr->assign([
Expand Down
2 changes: 1 addition & 1 deletion cypress/tests/integration/SubmissionWizard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe('Submission Wizard', function() {
cy.get('button:contains("Submit")').should('be.enabled');
});

cy.changeLanguage('Français');
cy.changeLanguage('français');
cy.get('button:contains("Continuer")').click();
cy.get('button:contains("Continuer")').click();
cy.get('button:contains("Continuer")').click();
Expand Down
14 changes: 7 additions & 7 deletions cypress/tests/integration/Z_ArticleViewDCMetadata.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('Article View Metadata - DC Plugin', function() {
]
},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeMetadata
.find(element => element.locale == 'fr_CA')
Expand All @@ -173,7 +173,7 @@ describe('Article View Metadata - DC Plugin', function() {
]
},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeTitles.fr_CA.abstract
]
Expand All @@ -184,7 +184,7 @@ describe('Article 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 @@ -207,7 +207,7 @@ describe('Article View Metadata - DC Plugin', function() {

},
{
locale: 'fr',
locale: 'fr-CA',
contents: [
submission.localeMetadata
.find(element => element.locale == 'fr_CA')
Expand All @@ -230,7 +230,7 @@ describe('Article View Metadata - DC Plugin', function() {
.values
},
{
locale: 'fr',
locale: 'fr-CA',
contents: submission.localeMetadata
.find(element => element.locale == 'fr_CA')
.manyValues
Expand Down Expand Up @@ -327,7 +327,7 @@ describe('Article View Metadata - DC Plugin', function() {
},
{
element: 'DC.Language',
scheme: 'ISO639-1',
scheme: 'rfc5646',
content: 'en'
},
{
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('Article View Metadata - DC Plugin', function() {
cy.wait(500);

// Enable dois
cy.checkDoiConfig(['publication', 'issue', 'representation']);
cy.checkDoiConfig(['publication', 'issue']);

// After configuration, go to submissions
cy.get('nav').contains('Dashboards').click();
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<migration class="PKP\migration\upgrade\v3_5_0\I9771_OrcidMigration"/>
<migration class="APP\migration\upgrade\v3_5_0\I5885_RenameReviewReminderSettingsName"/>
<migration class="PKP\migration\upgrade\v3_5_0\COA75_AddUserRoleEndEmail"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9707_WeblateUILocales"/>
</upgrade>

<!-- update plugin configuration - should be done as the final upgrade task -->
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
Submodule pkp updated 123 files
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/blocks/browse
2 changes: 1 addition & 1 deletion plugins/blocks/makeSubmission
4 changes: 3 additions & 1 deletion plugins/generic/datacite/filter/DataciteXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function &process(&$pubObject)
// Dates
$rootNode->appendChild($this->createDatesNode($doc, $issue, $article, $publication, $galley, $galleyFile, $publicationDate));
// Language
$rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'language', LocaleConversion::getIso1FromLocale($objectLocalePrecedence[0])));
$rootNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'language', str_replace(['_', '@'], '-', $objectLocalePrecedence[0])));
// Resource Type
$resourceTypeNode = $this->createResourceTypeNode($doc, $issue, $article, $galley, $galleyFile);
if ($resourceTypeNode) {
Expand Down Expand Up @@ -920,6 +920,8 @@ public function getObjectLocalePrecedence($context, $article, $publication, $gal
*
* @return string|null An OJS locale or null if no matching
* locale could be found.
*
* @deprecated 3.5
*/
public function translateLanguageToLocale($language)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public function articleView($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(substr($locale, 0, 2)) . '" 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(substr($locale, 0, 2)) . '" 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 @@ -115,7 +115,7 @@ public function articleView($hookName, $args)
$abstracts = $publication->getData('abstract') ?: [];
foreach ($abstracts as $locale => $abstract) {
if ($abstract != '') {
$templateMgr->addHeader('dublinCoreAbstract' . $locale, '<meta name="DC.Description" xml:lang="' . htmlspecialchars(substr($locale, 0, 2)) . '" 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 Down Expand Up @@ -146,7 +146,7 @@ public function articleView($hookName, $args)

$templateMgr->addHeader('dublinCoreUri', '<meta name="DC.Identifier.URI" content="' . $request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, 'article', 'view', [$articleBestId], 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 @@ -172,30 +172,30 @@ public function articleView($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(substr($locale, 0, 2)) . '" 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(substr($locale, 0, 2)) . '" content="' . htmlspecialchars($keyword) . '"/>');
$templateMgr->addHeader('dublinCoreKeyword' . $locale . $i++, '<meta name="DC.Subject" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($keyword) . '"/>');
}
}
}

$templateMgr->addHeader('dublinCoreTitle', '<meta name="DC.Title" content="' . htmlspecialchars($publication->getLocalizedFullTitle($publicationLocale)) . '"/>');
foreach ($publication->getFullTitles() as $locale => $title) {
if ($title != '' && $locale != $publicationLocale) {
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(substr($locale, 0, 2)) . '" content="' . htmlspecialchars($title) . '"/>');
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($title) . '"/>');
}
}

$templateMgr->addHeader('dublinCoreType', '<meta name="DC.Type" content="Text.Serial.Journal"/>');
if ($types = $publication->getData('type')) {
foreach ($types as $locale => $type) {
if ($type != '') {
$templateMgr->addHeader('dublinCoreType' . $locale, '<meta name="DC.Type" xml:lang="' . htmlspecialchars(substr($locale, 0, 2)) . '" 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
2 changes: 1 addition & 1 deletion plugins/generic/lensGalley
2 changes: 1 addition & 1 deletion plugins/generic/tinymce
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function &process(&$submissions)
$articleNode->appendChild($doiNode);
}

$articleNode->appendChild($doc->createElement('Language'))->appendChild($doc->createTextNode(LocaleConversion::get3LetterFrom2LetterIsoLanguage(substr($locale, 0, 2))));
$articleNode->appendChild($doc->createElement('Language'))->appendChild($doc->createTextNode(LocaleConversion::get3LetterIsoFromLocale($locale)));

$authorListNode = $doc->createElement('AuthorList');
foreach ($publication->getData('authors') ?? [] as $author) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/oaiMetadataFormats/oaiJats
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.
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.
File renamed without changes.
File renamed without changes.

0 comments on commit 0522b5c

Please sign in to comment.