jsoneditor
jsoneditor copied to clipboard
Add ajv-i18n support
Hello! Add i18n for validation error messges using ajv-i18n.
Thanks for your PR Alexey, this will be a nice improvement.
The PR itself is very hard to see what actually changed: about every line in textmode.js
and treemode.js
is changed. Can you please maintain the 2 space indentation, and if you would like to do any refactorings in the code do that in a separate PR?
Please note that you can run npm run lint
to detect linting issues, and use npm run lint -- --fix
to fix as much as possible automatically.
and use npm run lint -- --fix to fix as much as possible automatically.
Thanks!
I have fixed indents issues and now all checks have passed. Should i make new PR?
Thanks for the update, the code looks good 👍 . No need to create a new PR, I'll squash it when merging.
I'll test your work functionally soon.
I've done some testing, and it works like a charm, thanks @askalione!
Two feedbacks:
-
Bundling the full
ajv-i18n
is quite large: the minified+zipped bundle goes from 231KB to 244KB. I'm wondering whether we can come up with a solution which doesn't require bundling of all the locales. The only idea I can come up with is to have the user pass the right translation file himself via the options, like:const options = { language: 'ru' ajv-i18n: require('ajv-i18n/localize/ru') }
But that is not easy to use. Do you have any ideas in this regard? If not I guess we simply have to accept this for now.
-
JSONEditor has a minimalist version of the bundle which basically strips the Ace and Ajv, and color picker libraries. Since those are quite large. The
ajv-i18n
library is also stripped, but now thedist/jsoneditor-minimalist.js
throws an error when you open the editor with a JSONSchema. We can solve this by putting a try/catch around therequire
loadingajv-i18n
, the same way as is done for Ajv itself in the filetryRequireAjv.js
. Can you adjust that and make sure the code doesn't break whenajv-i18n
is not available in the bundle?