Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9707 use weblate locales for ui #4495

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<migration class="PKP\migration\upgrade\v3_5_0\I10041_UserGroupsAndUserUserGroupsMastheadValues"/>
<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\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 105 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.
2 changes: 1 addition & 1 deletion plugins/blocks/browse
23 changes: 0 additions & 23 deletions plugins/generic/datacite/filter/DataciteXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,29 +913,6 @@ public function getObjectLocalePrecedence($context, $article, $publication, $gal
return $locales;
}

/**
* Try to translate an ISO language code to an OJS locale.
*
* @param string $language 2- or 3-letter ISO language code
*
* @return string|null An OJS locale or null if no matching
* locale could be found.
*/
public function translateLanguageToLocale($language)
{
$locale = null;
if (strlen($language) == 2) {
$language = LocaleConversion::get3LetterFrom2LetterIsoLanguage($language);
}
if (strlen($language) == 3) {
$language = LocaleConversion::getLocaleFrom3LetterIso($language);
}
if (Locale::isLocaleValid($language)) {
$locale = $language;
}
return $locale;
}

/**
* Identify the primary translation from an array of
* localized data.
Expand Down
15 changes: 8 additions & 7 deletions plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use APP\facades\Repo;
use APP\template\TemplateManager;
use PKP\core\PKPApplication;
use PKP\i18n\LocaleConversion;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;

Expand Down Expand Up @@ -83,15 +84,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(LocaleConversion::getIso1FromLocale($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(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($coverage)) . '"/>');
}
}
}
Expand All @@ -115,7 +116,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(LocaleConversion::getIso1FromLocale($locale)) . '" content="' . htmlspecialchars(strip_tags($abstract)) . '"/>');
}
}

Expand Down Expand Up @@ -172,30 +173,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(LocaleConversion::getIso1FromLocale($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(LocaleConversion::getIso1FromLocale($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(LocaleConversion::getIso1FromLocale($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(LocaleConversion::getIso1FromLocale($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
Loading