josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
820 stars 108 forks source link

It is possible to use ajv-i18n in the editor? #254

Closed jamarciniak closed 1 year ago

jamarciniak commented 1 year ago

I am thinking, is it possible to use ajv-i18n to translate the ajv validation messages in the editor, or is it possible to translate the ajv messages in any other way?

josdejong commented 1 year ago

Yes, you can provide your own validator, and you can configure provided createAjvValidator as you like using the onCreateAjv parameter.

Looking at https://ajv.js.org/packages/ajv-i18n.html it requires calling a localization function on validation errors, so I guess it is easiest to write a wrapper function around createAjvValidator that first gets the validation errors, then apply localization, and then return them.