Skip to content

Commit

Permalink
feat(i18n): internationalize form error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Jan 29, 2021
1 parent 658a3a4 commit d6bfcec
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
6 changes: 1 addition & 5 deletions src/components/project-creation-card/ProjectCreationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
:placeholder="$t('Projects.ProjectCreationCard.inputName')"
v-model="newProject.name"
:error="error"
:errorMessage="errorMessage"
:errorMessage="$t('Projects.ProjectCreationCard.errorMessage')"
/>
<BIMDataButton fill radius color="primary"
class="creation-form__submit-btn"
Expand Down Expand Up @@ -71,7 +71,6 @@ export default {
const newProject = reactive({ name: '' });
const error = ref(false);
const errorMessage = ref('');
const createProject = () => {
if (newProject.name) {
loading.value = true;
Expand All @@ -82,7 +81,6 @@ export default {
} else {
nameInput.value.focus();
error.value = true;
errorMessage.value = 'You must provide a name for the project !';
}
};
Expand All @@ -94,14 +92,12 @@ export default {
const closeCreationForm = () => {
newProject.name = '';
error.value = false;
errorMessage.value = '';
showCreationForm.value = false;
};
return {
// References
error,
errorMessage,
loading,
nameInput,
newProject,
Expand Down
6 changes: 1 addition & 5 deletions src/components/project-update-form/ProjectUpdateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:placeholder="$t('Projects.ProjectUpdateForm.inputName')"
v-model="projectName"
:error="error"
:errorMessage="errorMessage"
:errorMessage="$t('Projects.ProjectUpdateForm.errorMessage')"
/>
<BIMDataButton fill radius color="primary"
class="project-update-form__submit-btn"
Expand Down Expand Up @@ -58,7 +58,6 @@ export default {
const nameInput = ref(null);
const projectName = ref(props.project.name);
const error = ref(false);
const errorMessage = ref('');
const renameProject = () => {
if (projectName.value) {
loading.value = true;
Expand All @@ -68,13 +67,11 @@ export default {
} else {
nameInput.value.focus();
error.value = true;
errorMessage.value = 'You must provide a name for the project !';
}
};
const close = () => {
error.value = false;
errorMessage.value = '';
emit('close');
};
Expand All @@ -85,7 +82,6 @@ export default {
return {
// References
error,
errorMessage,
nameInput,
projectName,
// Methods
Expand Down
6 changes: 1 addition & 5 deletions src/components/space-creation-card/SpaceCreationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
:placeholder="$t('Spaces.SpaceCreationCard.inputName')"
v-model="newSpace.name"
:error="error"
:errorMessage="errorMessage"
:errorMessage="$t('Spaces.SpaceCreationCard.errorMessage')"
/>
<BIMDataButton fill radius color="primary"
@click="createSpace">
Expand Down Expand Up @@ -60,7 +60,6 @@ export default {
const nameInput = ref(null);
const newSpace = reactive({ name: '' });
const error = ref(false);
const errorMessage = ref('');
const createSpace = () => {
if (newSpace.name) {
Expand All @@ -72,14 +71,12 @@ export default {
} else {
nameInput.value.focus();
error.value = true;
errorMessage.value = 'You must provide a name for the space !';
}
};
const close = () => {
newSpace.name = '';
error.value = false;
errorMessage.value = '';
emit('close');
};
Expand All @@ -90,7 +87,6 @@ export default {
return {
// References
error,
errorMessage,
loading,
nameInput,
newSpace,
Expand Down
6 changes: 1 addition & 5 deletions src/components/space-update-form/SpaceUpdateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:placeholder="$t('Spaces.SpaceRenameForm.inputName')"
v-model="spaceName"
:error="error"
:errorMessage="errorMessage"
:errorMessage="$t('Spaces.SpaceRenameForm.errorMessage')"
/>
<BIMDataButton fill radius color="primary"
class="space-update-form__submit-btn"
Expand Down Expand Up @@ -57,7 +57,6 @@ export default {
const nameInput = ref(null);
const spaceName = ref(props.space.name);
const error = ref(false);
const errorMessage = ref('');
const renameSpace = () => {
if (spaceName.value) {
loading.value = true;
Expand All @@ -67,13 +66,11 @@ export default {
} else {
nameInput.value.focus();
error.value = true;
errorMessage.value = 'You must provide a name for the space !';
}
};
const close = () => {
error.value = false;
errorMessage.value = '';
emit('close');
};
Expand All @@ -84,7 +81,6 @@ export default {
return {
// References
error,
errorMessage,
nameInput,
spaceName,
// Methods
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
title: 'New space',
inputName: 'Name',
buttonCreate: 'Create',
errorMessage: 'You must provide a name for the space !',
},
SpaceActionMenu: {
rename: 'Rename',
Expand All @@ -45,6 +46,7 @@ export default {
title: 'Rename space',
inputName: 'Name',
buttonRename: 'Rename',
errorMessage: 'Invalid space name.',
},
SpaceDeleteGuard: {
title: 'Delete space',
Expand All @@ -58,10 +60,11 @@ export default {
Projects: {
searchProjects: 'Search projets',
ProjectCreationCard: {
text: 'Create a new project',
title: 'New project',
inputName: 'Name',
buttonCreate: 'Create',
text: 'Create a new project',
errorMessage: 'You must provide a name for the project !',
},
ProjectActionMenu: {
rename: 'Rename',
Expand All @@ -71,6 +74,7 @@ export default {
title: 'Rename project',
inputName: 'Name',
buttonRename: 'Rename',
errorMessage: 'Invalid project name.',
},
ProjectDeleteGuard: {
title: 'Supprimer le projet',
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
title: 'Nouvel espace',
inputName: 'Nom',
buttonCreate: 'Créer',
errorMessage: 'Vous devez donner un nom à l\'espace !',
},
SpaceActionMenu: {
rename: 'Renommer',
Expand All @@ -45,6 +46,7 @@ export default {
title: 'Renommer l\'espace',
inputName: 'Nom',
buttonRename: 'Renommer',
errorMessage: 'Ce nom d\'espace n\'est pas valide.',
},
SpaceDeleteGuard: {
title: 'Supprimer l\'espace',
Expand All @@ -58,10 +60,11 @@ export default {
Projects: {
searchProjects: 'Rechercher un projet',
ProjectCreationCard: {
text: 'Créer un nouveau projet',
title: 'Nouveau projet',
inputName: 'Nom',
buttonCreate: 'Créer',
text: 'Créer un nouveau projet',
errorMessage: 'Vous devez donner un nom au projet !',
},
ProjectActionMenu: {
rename: 'Renommer',
Expand All @@ -71,6 +74,7 @@ export default {
title: 'Renommer le projet',
inputName: 'Nom',
buttonRename: 'Renommer',
errorMessage: 'Ce nom de projet n\'est pas valide.',
},
ProjectDeleteGuard: {
title: 'Supprimer le projet',
Expand Down

0 comments on commit d6bfcec

Please sign in to comment.