-
Notifications
You must be signed in to change notification settings - Fork 374
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
Ajv i18n example #1457
Ajv i18n example #1457
Conversation
Sounds like a new example! #1450 has been merged, you can rebase now. |
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.
Thank you!
Extend i18n example to demonstrate usage of ajv-i18n
Hey, I'm really appreciate your hard work on the package @Lily418 @edgarmueller . Would you mind sharing some more details regards how to implement the localization. Which packages are needed and how are they integrated into a JSONForms instance? |
Hi @LaszloDev ajv-i18n is the additional package. The JsonForms component has an onChange prop which is called when either data or errors is changed. This is the onChange I used in the example I here in this PR.
JsonForms uses AJV to validate the forms data against the schema so this library ajv-i18n can be used because the errors you receive in the onChange method are directly from AJV. |
This PR is to add an example of using the onChange handler and error update action (PR #1450) to show how a user of the library can add localisation of the errors with i18n.
4c5a9fe is the new commit, others will be rebased away when #1450 is complete.
ajv-i18n in core
I had initally been adding ajv-i18n to the core package, however this became complex when trying to combine navigator languages, selected locale from i18n reducer, and languages supported by ajv-i18n.
There are a few cases to consider
I think it is better for the user of JsonForms to implement this logic so they can implement i18n logic consistantly rather than enforcing a specific method on the user.
It may be possible for the user to provide their own language selection logic to JSONForms but I decided to try to keep it simple for now.