Internationalization
Translated errors
Error messages are translated using ajv-i18n.
Locale refs
Schemas can contain internationalized content thanks to a conventional ~$locale~ variable in ref paths.
These refs will be resolved by replacing ~$locale~ with the current locale, and if the resolution fails it will be attempted again with the defaultLocale option.
Warning: this resolution method is not a part of JSON schema or any other specification, schemas that use it will be incompatible with other tooling. You might want to use our method resolveLocaleRefs in your code:
import { resolveLocaleRefs } from '@json-layout/core
resolveLocaleRefs(schema, ajv, locale)
x-i18n-* annotations
Schemas can contain internationalized content thanks to x-i18n-* annotations.
These annotations contain objects with locales as keys, the content will be resolved using the current locale and will replace the schema property matching the annotation.
This functionality must be activated using the xI18n option.
Contrary to the use of the ~$locale~ variable, this system does not break the compatibility of the schema with any existing tooling. You might want to use our method resolveXI18n in your code:
import { resolveXI18n } from '@json-layout/core
resolveXI18n(schema, locale)
Messages
JSON layout uses a few messages by itself. These messages are internationalized and can be overwritten through the global options messages or locally on a node with layout.messages.