-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/intl form implementation #101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're nearly there, some small remarks though. After fixing:
- Can you run
npm run compilemessages
(don't forget to add the english translation first) - Can you investigate how to test this in Storybook?
src/components/form/form/form.tsx
Outdated
@@ -205,11 +217,16 @@ export const Form: React.FC<FormProps> = ({ | |||
getValueFromFormData(fields, valuesState, field); | |||
|
|||
const error = getErrorFromErrors(fields, errorsState, field); | |||
const message = | |||
error === 'Veld "{name}" is verplicht' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to a constants somwhere next to the validator? And us it a much as possible (except for the useInt.formatMessage
call which needs to be a string literal)?
src/lib/form/validation.ts
Outdated
@@ -18,7 +18,7 @@ export type Validator = ( | |||
export const validateRequired: Validator = ( | |||
value, | |||
field, | |||
message = 'Field "{name}" is required', | |||
message = 'Veld "{name}" is verplicht', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can be a constant, optionally document form behaviour overriding the final label
src/lib/i18n/messages/en.json
Outdated
@@ -104,6 +104,11 @@ | |||
"description": "mykn.components.Form: The submit form label", | |||
"originalDefault": "verzenden" | |||
}, | |||
"mykn.components.Form.labelValidationErrorRequired": { | |||
"defaultMessage": "Veld {name} is verplicht", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one needs to be translated
No description provided.