Skip to content

Commit

Permalink
feat: password missing translation (#510)
Browse files Browse the repository at this point in the history
* feat: Add password translation in auth.json

* feat: Add useTranslation on FieldPassword

* feat: Replace translation + adapt FiledPassword

* feat: Rename hide and show password

* feat: Remove common

---------

Co-authored-by: Nikola LEGAY <[email protected]>
  • Loading branch information
Nikola-BS and Nikola LEGAY authored Jul 26, 2024
1 parent 50a42bf commit 8edad0d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Form/FieldPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -38,6 +39,7 @@ export const FieldPassword = <
>(
props: FieldPasswordProps<TFieldValues, TName>
) => {
const { t } = useTranslation(['components']);
const [showPassword, setShowPassword] = useState(false);
return (
<Controller
Expand All @@ -56,7 +58,11 @@ export const FieldPassword = <
<IconButton
isDisabled={props.isDisabled}
onClick={() => setShowPassword((x) => !x)}
aria-label={showPassword ? 'Hide password' : 'Show password'} // TODO: translation
aria-label={
showPassword
? t('components:fieldPassword.hidePassword')
: t('components:fieldPassword.showPassword')
}
display="flex"
size="xs"
fontSize="lg"
Expand Down
4 changes: 4 additions & 0 deletions src/locales/ar/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@
},
"formField": {
"optional": "خياري"
},
"fieldPassword": {
"showPassword": "عرض كلمة المرور",
"hidePassword": "إخفاء كلمة المرور"
}
}
4 changes: 4 additions & 0 deletions src/locales/en/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@
"november": "November",
"december": "December"
}
},
"fieldPassword": {
"showPassword": "Show password",
"hidePassword": "Hide password"
}
}
4 changes: 4 additions & 0 deletions src/locales/fr/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@
},
"formField": {
"optional": "Facultatif"
},
"fieldPassword": {
"showPassword": "Afficher le mot de passe",
"hidePassword": "Masquer le mot de passe"
}
}
4 changes: 4 additions & 0 deletions src/locales/sw/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,9 @@
},
"formField": {
"optional": "Hiari"
},
"fieldPassword": {
"showPassword": "Onyesha nenosiri",
"hidePassword": "Ficha nenosiri"
}
}

0 comments on commit 8edad0d

Please sign in to comment.