From b70b260e8226018d34874512bfe3b4662ef56c14 Mon Sep 17 00:00:00 2001 From: Nikola LEGAY Date: Wed, 24 Jul 2024 09:22:42 +0200 Subject: [PATCH 1/5] feat: Add password translation in auth.json --- src/locales/ar/auth.json | 4 ++++ src/locales/en/auth.json | 4 ++++ src/locales/fr/auth.json | 4 ++++ src/locales/sw/auth.json | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/locales/ar/auth.json b/src/locales/ar/auth.json index d08ad937d..c38dac711 100644 --- a/src/locales/ar/auth.json +++ b/src/locales/ar/auth.json @@ -50,5 +50,9 @@ }, "description": "لقد أرسلنا رمزًا مكونًا من 6 أحرف إلى {{email}} وتنتهي صلاحية الرمز قريبًا ({{expiration}} دقيقة).", "title": "تحقق من صندوق الوارد الخاص بك للحصول على الرمز" + }, + "password": { + "show": "عرض كلمة المرور", + "hide": "إخفاء كلمة المرور" } } diff --git a/src/locales/en/auth.json b/src/locales/en/auth.json index 14bf889f8..a8d68f1a8 100644 --- a/src/locales/en/auth.json +++ b/src/locales/en/auth.json @@ -50,5 +50,9 @@ "language": { "label": "Language" } + }, + "password": { + "show": "Show password", + "hide": "Hide password" } } diff --git a/src/locales/fr/auth.json b/src/locales/fr/auth.json index 1178bf7f0..2f31c0a23 100644 --- a/src/locales/fr/auth.json +++ b/src/locales/fr/auth.json @@ -50,5 +50,9 @@ }, "description": "Nous avons envoyé un code à 6 caractères à {{email}} Le code expire sous peu ({{expiration}} minutes).", "title": "Vérifiez votre boîte de réception pour le code" + }, + "password": { + "show": "Afficher le mot de passe", + "hide": "Masquer le mot de passe" } } diff --git a/src/locales/sw/auth.json b/src/locales/sw/auth.json index 83fbbb171..4af7bc4a5 100644 --- a/src/locales/sw/auth.json +++ b/src/locales/sw/auth.json @@ -50,5 +50,9 @@ }, "description": "Tumetuma msimbo wa herufi 6 kwa {{email}} Nambari hii itaisha muda mfupi (dakika {{expiration}}).", "title": "Angalia kisanduku pokezi chako kwa msimbo" + }, + "password": { + "show": "Onyesha nenosiri", + "hide": "Ficha nenosiri" } } From 0e2e972eb370a803aac8597099f294430808fe79 Mon Sep 17 00:00:00 2001 From: Nikola LEGAY Date: Wed, 24 Jul 2024 09:27:21 +0200 Subject: [PATCH 2/5] feat: Add useTranslation on FieldPassword --- src/components/Form/FieldPassword/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Form/FieldPassword/index.tsx b/src/components/Form/FieldPassword/index.tsx index d8181f61d..06686c2ab 100644 --- a/src/components/Form/FieldPassword/index.tsx +++ b/src/components/Form/FieldPassword/index.tsx @@ -16,6 +16,7 @@ import { FieldPath, FieldValues, } from 'react-hook-form'; +import { useTranslation } from 'react-i18next'; import { RiEyeCloseLine, RiEyeLine } from 'react-icons/ri'; import { FieldCommonProps } from '@/components/Form/FormFieldController'; @@ -38,6 +39,7 @@ export const FieldPassword = < >( props: FieldPasswordProps ) => { + const { t } = useTranslation(); const [showPassword, setShowPassword] = useState(false); return ( setShowPassword((x) => !x)} - aria-label={showPassword ? 'Hide password' : 'Show password'} // TODO: translation + aria-label={ + showPassword + ? t('password.hide', 'Hide password') + : t('password.show', 'Show password') + } display="flex" size="xs" fontSize="lg" From 2cc90a39397c5e8a3a3f60e25b87a19b54be9be7 Mon Sep 17 00:00:00 2001 From: Nikola LEGAY Date: Wed, 24 Jul 2024 11:16:03 +0200 Subject: [PATCH 3/5] feat: Replace translation + adapt FiledPassword --- src/components/Form/FieldPassword/index.tsx | 6 +++--- src/locales/ar/auth.json | 4 ---- src/locales/ar/components.json | 4 ++++ src/locales/en/auth.json | 4 ---- src/locales/en/components.json | 4 ++++ src/locales/fr/auth.json | 4 ---- src/locales/fr/components.json | 4 ++++ src/locales/sw/auth.json | 4 ---- src/locales/sw/components.json | 4 ++++ 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/Form/FieldPassword/index.tsx b/src/components/Form/FieldPassword/index.tsx index 06686c2ab..5b85961c6 100644 --- a/src/components/Form/FieldPassword/index.tsx +++ b/src/components/Form/FieldPassword/index.tsx @@ -39,7 +39,7 @@ export const FieldPassword = < >( props: FieldPasswordProps ) => { - const { t } = useTranslation(); + const { t } = useTranslation(['common', 'components']); const [showPassword, setShowPassword] = useState(false); return ( setShowPassword((x) => !x)} aria-label={ showPassword - ? t('password.hide', 'Hide password') - : t('password.show', 'Show password') + ? t('components:fieldPassword.passwordHide') + : t('components:fieldPassword.passwordShow') } display="flex" size="xs" diff --git a/src/locales/ar/auth.json b/src/locales/ar/auth.json index c38dac711..d08ad937d 100644 --- a/src/locales/ar/auth.json +++ b/src/locales/ar/auth.json @@ -50,9 +50,5 @@ }, "description": "لقد أرسلنا رمزًا مكونًا من 6 أحرف إلى {{email}} وتنتهي صلاحية الرمز قريبًا ({{expiration}} دقيقة).", "title": "تحقق من صندوق الوارد الخاص بك للحصول على الرمز" - }, - "password": { - "show": "عرض كلمة المرور", - "hide": "إخفاء كلمة المرور" } } diff --git a/src/locales/ar/components.json b/src/locales/ar/components.json index a4f901a22..dfba71ad4 100644 --- a/src/locales/ar/components.json +++ b/src/locales/ar/components.json @@ -89,5 +89,9 @@ }, "formField": { "optional": "خياري" + }, + "fieldPassword": { + "passwordShow": "عرض كلمة المرور", + "passwordHide": "إخفاء كلمة المرور" } } diff --git a/src/locales/en/auth.json b/src/locales/en/auth.json index a8d68f1a8..14bf889f8 100644 --- a/src/locales/en/auth.json +++ b/src/locales/en/auth.json @@ -50,9 +50,5 @@ "language": { "label": "Language" } - }, - "password": { - "show": "Show password", - "hide": "Hide password" } } diff --git a/src/locales/en/components.json b/src/locales/en/components.json index 3503ae2da..d9fb20fd8 100644 --- a/src/locales/en/components.json +++ b/src/locales/en/components.json @@ -89,5 +89,9 @@ "november": "November", "december": "December" } + }, + "fieldPassword": { + "passwordShow": "Show password", + "passwordHide": "Hide password" } } diff --git a/src/locales/fr/auth.json b/src/locales/fr/auth.json index 2f31c0a23..1178bf7f0 100644 --- a/src/locales/fr/auth.json +++ b/src/locales/fr/auth.json @@ -50,9 +50,5 @@ }, "description": "Nous avons envoyé un code à 6 caractères à {{email}} Le code expire sous peu ({{expiration}} minutes).", "title": "Vérifiez votre boîte de réception pour le code" - }, - "password": { - "show": "Afficher le mot de passe", - "hide": "Masquer le mot de passe" } } diff --git a/src/locales/fr/components.json b/src/locales/fr/components.json index 91833cc67..49f2641d3 100644 --- a/src/locales/fr/components.json +++ b/src/locales/fr/components.json @@ -89,5 +89,9 @@ }, "formField": { "optional": "Facultatif" + }, + "fieldPassword": { + "passwordShow": "Afficher le mot de passe", + "passwordHide": "Masquer le mot de passe" } } diff --git a/src/locales/sw/auth.json b/src/locales/sw/auth.json index 4af7bc4a5..83fbbb171 100644 --- a/src/locales/sw/auth.json +++ b/src/locales/sw/auth.json @@ -50,9 +50,5 @@ }, "description": "Tumetuma msimbo wa herufi 6 kwa {{email}} Nambari hii itaisha muda mfupi (dakika {{expiration}}).", "title": "Angalia kisanduku pokezi chako kwa msimbo" - }, - "password": { - "show": "Onyesha nenosiri", - "hide": "Ficha nenosiri" } } diff --git a/src/locales/sw/components.json b/src/locales/sw/components.json index a95f6553f..090c0be2c 100644 --- a/src/locales/sw/components.json +++ b/src/locales/sw/components.json @@ -89,5 +89,9 @@ }, "formField": { "optional": "Hiari" + }, + "fieldPassword": { + "passwordShow": "Onyesha nenosiri", + "passwordHide": "Ficha nenosiri" } } From 678d371e2366044e2c68e535bb2bb48a52992507 Mon Sep 17 00:00:00 2001 From: Nikola LEGAY Date: Wed, 24 Jul 2024 16:50:07 +0200 Subject: [PATCH 4/5] feat: Rename hide and show password --- src/components/Form/FieldPassword/index.tsx | 4 ++-- src/locales/ar/components.json | 4 ++-- src/locales/en/components.json | 4 ++-- src/locales/fr/components.json | 4 ++-- src/locales/sw/components.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Form/FieldPassword/index.tsx b/src/components/Form/FieldPassword/index.tsx index 5b85961c6..0f9491ff1 100644 --- a/src/components/Form/FieldPassword/index.tsx +++ b/src/components/Form/FieldPassword/index.tsx @@ -60,8 +60,8 @@ export const FieldPassword = < onClick={() => setShowPassword((x) => !x)} aria-label={ showPassword - ? t('components:fieldPassword.passwordHide') - : t('components:fieldPassword.passwordShow') + ? t('components:fieldPassword.hidePassword') + : t('components:fieldPassword.showPassword') } display="flex" size="xs" diff --git a/src/locales/ar/components.json b/src/locales/ar/components.json index dfba71ad4..65ab5ad6e 100644 --- a/src/locales/ar/components.json +++ b/src/locales/ar/components.json @@ -91,7 +91,7 @@ "optional": "خياري" }, "fieldPassword": { - "passwordShow": "عرض كلمة المرور", - "passwordHide": "إخفاء كلمة المرور" + "showPassword": "عرض كلمة المرور", + "hidePassword": "إخفاء كلمة المرور" } } diff --git a/src/locales/en/components.json b/src/locales/en/components.json index d9fb20fd8..6d24e97b7 100644 --- a/src/locales/en/components.json +++ b/src/locales/en/components.json @@ -91,7 +91,7 @@ } }, "fieldPassword": { - "passwordShow": "Show password", - "passwordHide": "Hide password" + "showPassword": "Show password", + "hidePassword": "Hide password" } } diff --git a/src/locales/fr/components.json b/src/locales/fr/components.json index 49f2641d3..9e7391420 100644 --- a/src/locales/fr/components.json +++ b/src/locales/fr/components.json @@ -91,7 +91,7 @@ "optional": "Facultatif" }, "fieldPassword": { - "passwordShow": "Afficher le mot de passe", - "passwordHide": "Masquer le mot de passe" + "showPassword": "Afficher le mot de passe", + "hidePassword": "Masquer le mot de passe" } } diff --git a/src/locales/sw/components.json b/src/locales/sw/components.json index 090c0be2c..66f4ba5b0 100644 --- a/src/locales/sw/components.json +++ b/src/locales/sw/components.json @@ -91,7 +91,7 @@ "optional": "Hiari" }, "fieldPassword": { - "passwordShow": "Onyesha nenosiri", - "passwordHide": "Ficha nenosiri" + "showPassword": "Onyesha nenosiri", + "hidePassword": "Ficha nenosiri" } } From ae681cc48cba3ef66ff37ffd1486e05854d82dbb Mon Sep 17 00:00:00 2001 From: Nikola LEGAY Date: Wed, 24 Jul 2024 17:09:55 +0200 Subject: [PATCH 5/5] feat: Remove common --- src/components/Form/FieldPassword/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Form/FieldPassword/index.tsx b/src/components/Form/FieldPassword/index.tsx index 0f9491ff1..7efe54a15 100644 --- a/src/components/Form/FieldPassword/index.tsx +++ b/src/components/Form/FieldPassword/index.tsx @@ -39,7 +39,7 @@ export const FieldPassword = < >( props: FieldPasswordProps ) => { - const { t } = useTranslation(['common', 'components']); + const { t } = useTranslation(['components']); const [showPassword, setShowPassword] = useState(false); return (