Skip to content

Commit

Permalink
chore: add translation for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
KabinKhandThakuri committed Jan 6, 2025
1 parent 7454394 commit e59cffd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vue-user/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export { default as PasswordResetRequestForm } from "./PasswordResetRequestForm.
export { default as SignInUpMenu } from "./SignInUpMenu.vue";
export { default as SignupForm } from "./SignupForm.vue";
export { default as TermsAndConditions } from "./TermsAndConditions.vue";
export { default as UpdateEmailForm } from "./profile/UpdateEmailForm.vue";
export { default as UserMenu } from "./UserMenu.vue";
13 changes: 11 additions & 2 deletions packages/vue-user/src/components/profile/UpdateEmailForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<Form @submit="onSubmit">
<Email label="new Email" name="email" />
<Email
:error-messages="errorMessages"
:label="t('profile.accountInfo.newEmail')"
name="email"
/>

<FormActions :loading="loading" />
</Form>
Expand Down Expand Up @@ -32,6 +36,11 @@ const messages = useTranslations();
const { setUser, user } = useUserStore();
const { t } = useI18n({ messages });
const errorMessages = {
invalid: t("profile.accountInfo.messages.invalid"),
required: t("profile.accountInfo.messages.email"),
};
const loading = ref<boolean>(false);
const onSubmit = async (data: UpdateEmailFormData) => {
Expand All @@ -46,7 +55,7 @@ const onSubmit = async (data: UpdateEmailFormData) => {
if (config.user?.features?.signUp?.emailVerification && isSameEmail) {
emitter.emit("notify", {
text: "A verification link has been sent to your email.",
text: t("profile.accountInfo.messages.emailSent"),
type: "success",
});
} else {
Expand Down
30 changes: 30 additions & 0 deletions packages/vue-user/src/locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@
"title": "Reset your password"
},
"profile": {
"accountInfo": {
"label": "Email",
"newEmail": "New Email",
"messages": {
"alreadyExist": "Email already exists.",
"duplicate": "Email is same as the current one.",
"disabled": "Update email feature is currently disabled.",
"email": "Email is required.",
"emailSent": "A verification link has been sent to your email.",
"error": "An error occurred while updating the email.",
"invalid": "Invalid email",
"success": "Email updated successfully.",
"verify": "Verify email to complete the email update."
}
},
"title": "Profile"
},
"signup": {
Expand Down Expand Up @@ -335,6 +350,21 @@
"title": "Réinitialisation de votre mot de passe"
},
"profile": {
"accountInfo": {
"label": "Email",
"newEmail": "New Email",
"messages": {
"alreadyExist": "Email already exists.",
"duplicate": "Email is same as the current one.",
"disabled": "Update email feature is currently disabled.",
"email": "Email is required.",
"emailSent": "A verification link has been sent to your email.",
"error": "An error occurred while updating the email.",
"invalid": "Invalid email",
"success": "Email updated successfully.",
"verify": "Verify email to complete the email update."
}
},
"title": "Profil"
},
"signup": {
Expand Down

0 comments on commit e59cffd

Please sign in to comment.