Skip to content

Commit 09e4ca3

Browse files
pkp/pkp-lib#10820 Add locale keys for new error summary message
1 parent 897f487 commit 09e4ca3

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

public/globals.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ window.pkp = {
431431
'form.errorOne': 'Please correct one error.',
432432
'form.errors':
433433
'The form was not saved because {$count} error(s) were encountered. Please correct these errors and try again.',
434+
'form.errorSummaryOne':
435+
'1 error detected! Please correct the error below before proceeding.',
436+
'form.errorSummaryMany':
437+
'{$count} errors detected! Please correct the errors below before proceeding.',
434438
'form.multilingualLabel': '{$label} in {$localeName}',
435439
'form.multilingualProgress': '{$count}/{$total} languages completed',
436440
'form.saved': 'Saved',
@@ -454,8 +458,8 @@ window.pkp = {
454458
'grid.noItems': 'No Items',
455459
'grid.user.confirmLogInAs':
456460
'Log in as this user? All actions you perform will be attributed to this user.',
457-
'grid.user.currentUsers':'Current Users',
458-
'grid.action.mergeUser':'Merge User',
461+
'grid.user.currentUsers': 'Current Users',
462+
'grid.action.mergeUser': 'Merge User',
459463
'help.help': 'Help',
460464
'informationCenter.informationCenter': 'Information Center',
461465
'invitation.cancelInvite.actionName': 'Cancel Invite',

src/components/Form/Form.stories.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -133,32 +133,34 @@ export const WithErrorSummary = {
133133
components: {PkpForm: Form, FormErrorSummary},
134134
setup() {
135135
const {get, set, components} = useContainerStateManager();
136-
const errors = {
137-
email: ['Please provide a valid email address'],
138-
affiliation: {
139-
en: ['You must enter your affiliation in English.'],
140-
fr_CA: ['You must enter your affiliation in French.'],
141-
ar: ['You must enter your affiliation in Arabic.'],
142-
},
143-
'user-locales': ['You must select at least two options.'],
144-
bio: {
145-
en: ['Please provide a bio statement to accompany your publication.'],
146-
},
147-
country: ['Please select your country.'],
148-
'mailing-address': [
149-
'You must enter a mailing address where you can receive post.',
150-
],
151-
};
152-
set('errorSummary', {
136+
set('example', {
153137
...FormUser,
154138
...args,
155-
errors,
139+
errors: {
140+
email: ['Please provide a valid email address'],
141+
affiliation: {
142+
en: ['You must enter your affiliation in English.'],
143+
fr_CA: ['You must enter your affiliation in French.'],
144+
ar: ['You must enter your affiliation in Arabic.'],
145+
},
146+
'user-locales': ['You must select at least two options.'],
147+
bio: {
148+
en: [
149+
'Please provide a bio statement to accompany your publication.',
150+
],
151+
},
152+
country: ['Please select your country.'],
153+
'mailing-address': [
154+
'You must enter a mailing address where you can receive post.',
155+
],
156+
},
156157
});
157-
return {args, errors, get, set, components};
158+
159+
return {args, get, set, components};
158160
},
159161
template: `
160-
<FormErrorSummary :errors="errors"/>
161-
<PkpForm v-bind="components.errorSummary" @set="set" />
162+
<FormErrorSummary :errors="components.example.errors"/>
163+
<PkpForm v-bind="components.example" @set="set" />
162164
`,
163165
}),
164166

src/components/Form/FormErrorSummary.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<script setup>
1616
import {computed} from 'vue';
1717
import Icon from '@/components/Icon/Icon.vue';
18+
import {useLocalize} from '@/composables/useLocalize';
19+
20+
const {t} = useLocalize();
1821
1922
const props = defineProps({
2023
errors: {
@@ -26,7 +29,10 @@ const props = defineProps({
2629
const errorsCount = computed(() => Object.keys(props.errors).length);
2730
2831
const message = computed(() => {
29-
const error = errorsCount.value > 1 ? 'errors' : 'error';
30-
return `${errorsCount.value} ${error} detected! Please correct the following ${error} before proceeding.`;
32+
const count = errorsCount.value;
33+
if (count > 1) {
34+
return t('form.errorSummaryMany', {count});
35+
}
36+
return t('form.errorSummaryOne');
3137
});
3238
</script>

0 commit comments

Comments
 (0)