From 11af3b6adb0e3ae49855dc00321491db70820e8c Mon Sep 17 00:00:00 2001 From: JATIN Date: Mon, 10 Feb 2025 22:29:47 +0530 Subject: [PATCH 1/3] Fix Login Page Translation Error: "Invalid Username or Password" i Just Add the Translation for the backend Error response in Each language to fix these issue and a translateSubmitError. --- client/modules/User/components/LoginForm.jsx | 15 ++++++++++++++- translations/locales/be/translations.json | 6 +++++- translations/locales/de/translations.json | 7 ++++++- translations/locales/en-US/translations.json | 6 +++++- translations/locales/es-419/translations.json | 6 +++++- translations/locales/fr-CA/translations.json | 6 +++++- translations/locales/hi/translations.json | 6 +++++- translations/locales/it/translations.json | 6 +++++- translations/locales/ja/translations.json | 6 +++++- translations/locales/ko/translations.json | 6 +++++- translations/locales/pt-BR/translations.json | 6 +++++- translations/locales/sv/translations.json | 6 +++++- translations/locales/tr/translations.json | 6 +++++- translations/locales/uk-UA/translations.json | 6 +++++- translations/locales/ur/translations.json | 6 +++++- translations/locales/zh-CN/translations.json | 6 +++++- translations/locales/zh-TW/translations.json | 6 +++++- 17 files changed, 95 insertions(+), 17 deletions(-) diff --git a/client/modules/User/components/LoginForm.jsx b/client/modules/User/components/LoginForm.jsx index 42441861fa..7c79a22c05 100644 --- a/client/modules/User/components/LoginForm.jsx +++ b/client/modules/User/components/LoginForm.jsx @@ -24,6 +24,16 @@ function LoginForm() { useSyncFormTranslations(formRef, i18n.language); + const translateSubmitError = (error) => { + const errorMessages = { + 'Invalid credentials': t('LoginForm.Errors.invalidCredentials'), + 'Invalid username or password.': t('LoginForm.Errors.invalidCredentials'), + 'Network error': t('LoginForm.Errors.networkError') + // Add more mappings as needed + }; + return errorMessages[error] || error; // Fallback to the original error if no translation is found + }; + return (
{submitError && !modifiedSinceLastSubmit && ( - {submitError} + + {' '} + {translateSubmitError(submitError)} + )}