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

Submission and metadata languages separated from UI and form languages #4040

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

jyhein
Copy link
Contributor

@jyhein jyhein commented Sep 18, 2023

  • In Website Settings > Setup > Languages and in Administration > Hosted Journals > Settings Wizard > Journal Settings > Languages, separate Website Languages and Submission Languages settings. In the website languages are UI and Forms, and in the submission languages are submission and metadata.

  • Submission metadata can be edited even if metadata isn't checked in that language in the settings.

@jyhein
Copy link
Contributor Author

jyhein commented Sep 20, 2023

Hey @asmecher,

I have PRs ready for review of the code...

PKP: pkp/pkp-lib#9309
OJS: #4040
OMP: pkp/omp#1461

@asmecher
Copy link
Member

Thanks, @jyhein! @bozana, would you be able to review these?

@bozana
Copy link
Contributor

bozana commented Oct 4, 2023

I will take/am taking a look... It will take some time because I would also like to test it locally...

@bozana
Copy link
Contributor

bozana commented Oct 9, 2023

@jyhein, could we not user the journal primary locale for supportedDefaultSubmissionLocale?
Also, should maybe journal primary locale always be part of supportedAddedSubmissionLocales, supportedSubmissionLocales, and supportedSubmissionMetadataLocales?
Just asking to understand your decisions i.e. cases I maybe do not have on my mind, or technical difficulties I do not have on my mind or...

@bozana
Copy link
Contributor

bozana commented Oct 9, 2023

And maybe one more question right away, for me to understand it better when looking into the code:
I see, the submission (primary) locale is not necessarily in the list of supported metadata locales. How/when is this possible?
E.g.

$primaryLocale = $submission->getData('locale');
$allowedLocales = $context->getSupportedSubmissionMetadataLocales();
in_array($primaryLocale, $allowedLocales) || array_push($allowedLocales, $primaryLocale);

EDIT:
Oh, after our meeting I think I know the reason/case here: when journal has disabled a language that was used earlier, in which submissions already exist...

Copy link
Contributor

@bozana bozana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, great work @jyhein!

// supportedFormLocales, supportedLocales, supportedSubmissionLocales
$settingNames = "('supportedFormLocales', 'supportedLocales', 'supportedSubmissionLocales')";
// supportedFormLocales, supportedLocales, supportedAddedSubmissionLocales, supportedSubmissionLocales, supportedDefaultSubmissionLocale, supportedSubmissionMetadataLocales
$settingNames = "('supportedFormLocales', 'supportedLocales', 'supportedAddedSubmissionLocales', 'supportedSubmissionLocales', 'supportedDefaultSubmissionLocale', 'supportedSubmissionMetadataLocales')";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This upgrade function will only be executed for journals using version 3.1. Thus they will not have those settings, so I think this should not be considered here.

$primaryLocale = $submission->getLocale();
$primaryLocale = $submission->getData('locale');
$allowedLocales = $context->getSupportedSubmissionMetadataLocales();
in_array($primaryLocale, $allowedLocales) || array_push($allowedLocales, $primaryLocale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more readable to use if statement:
if (!in_array($primaryLocale, $allowedLocales) ) { array_push($allowedLocales, $primaryLocale); }
Here and everywhere else in the code.

@@ -85,8 +85,9 @@ public function setupIndex($request)
$submissionContext = Services::get('context')->get($submission->getContextId());
}

$locales = $submissionContext->getSupportedSubmissionLocaleNames();
$locales = $submissionContext->getSupportedSubmissionMetadataLocaleNames() + [$submission->getData('locale') => (new \PKP\i18n\LocaleMetadata($submission->getData('locale')))->getDisplayName(null, false)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use:
use PKP\i18n\LocaleMetadata;
at the beginning of the file.

@jyhein
Copy link
Contributor Author

jyhein commented Oct 27, 2023

Hey @bozana,
OJS is ready with changes.
PKP PR has comments to changes: pkp/pkp-lib#9309

@jyhein jyhein force-pushed the f5000_7431 branch 2 times, most recently from 695c29c to 24ead38 Compare October 31, 2023 12:45
$allowedLocales = $context->getSupportedSubmissionLocales();
$primaryLocale = $submission->getLocale();
$primaryLocale = $submission->getData('locale');
$allowedLocales = array_values(array_unique(array_merge($context->getSupportedSubmissionMetadataLocales(), $publication?->getLanguages() ?? [$primaryLocale])));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already considered in the parent::validate() or?

@@ -62,17 +62,15 @@ public function __construct($request, $submission, $publication, $articleGalley
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));

// Ensure a locale is provided and valid
$journal = $request->getJournal();
$locales = $request->getJournal()->getSupportedSubmissionMetadataLocaleNames() + $publication->getLanguageNames();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The galley's locale, that has been removed, is not considered here, and maybe somewhere else too.
For example, this scenario:
EN, DE and FR are selected as submission locales.
Author submits an article in EN, with EN metadata.
Editor creates later a galley in DE, without entering DE metadata.
DE is removed as metadata locale (that means also as submission locale).
The galley in DE can not be edited correctly, its earlier locale is not considered.
I.e. galleys are connected with allowed submission locales -- a galley can be created in any enabled submission locale. It could happen -- probably rarely, but it could happen -- that there is only galley (and no metadata) in a different language than the submission primary language.

(The galleys locales tell us in which language a submission exists -- relevant to the removal of the DC language metadata field).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add galleys/ publication formats (omp) locales to PKPPublication getLanguages-function then they would always be included ?

Copy link
Contributor

@bozana bozana Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... Now that I think about it...
I think galley locale can only be one of supportedSubmissionLocales, and not getSupportedSubmissionMetadataLocales. In order to consider the removed locales, the galley forms need to consider galleys locales too.
I like the idea of having everything at one place, in that function getLanguages(), also the galleys locales. The function however is then only relevant for metadata and not for galleys forms, I think... 🤔

@jyhein jyhein force-pushed the f5000_7431 branch 2 times, most recently from 3988aaa to 2bd33bd Compare November 14, 2023 12:56
@jyhein jyhein force-pushed the f5000_7431 branch 6 times, most recently from 162366e to 2994581 Compare February 7, 2024 10:35
@jyhein jyhein force-pushed the f5000_7431 branch 4 times, most recently from 38dfc02 to 29aec7b Compare February 20, 2024 07:55
$this->addCheck(
new \PKP\form\validation\FormValidator(
$this,
'locale',
'required',
'editor.issues.galleyLocaleRequired'
),
function ($locale) use ($journal) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not correct: addCheck only accepts one parameter, so I think this would need to be FormValidatorCustom, that will then have this function as parameter.
Could you please change it?

@jyhein jyhein force-pushed the f5000_7431 branch 3 times, most recently from 51ef640 to 10aecc6 Compare March 13, 2024 10:17
@bozana bozana merged commit afcf029 into pkp:main Mar 21, 2024
3 checks passed
@jyhein jyhein deleted the f5000_7431 branch April 25, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants