# ajv-i18n
Internationalised error messages for [Ajv](https://github.com/epoberezkin/ajv) - currently the fastest JSON-Schema validator
[](https://travis-ci.org/ajv-validator/ajv-i18n)
[](https://www.npmjs.com/package/ajv-i18n)
[](https://coveralls.io/github/ajv-validator/ajv-i18n?branch=master)
[](https://gitter.im/ajv-validator/ajv)
## Supported locales
|locale|language |contributor|draft-04|draft-06\*|draft-07\*\*|
|------|:-------:|:---------:|:------:|:------:|:------:|
|๐ฌ๐ง en|English | |โ|โ|โ|
|AR ar|Arabic |[Mahmoud-Mardeni](https://github.com/Mahmoud-Mardeni)|โ|โ|โ|
|CA ca|Catalan |[alexandreec](https://github.com/alexandreec)|โ|โ|โ|
|๐จ๐ฟ cz|Czech |[kiskovacs](https://github.com/kiskovacs)
[NAM0007](https://github.com/NAM0007)|โ
|โ
|
โ|
|๐ฉ๐ช de|German |[jmtoball](https://github.com/jmtoball)
[gflohr](https://github.com/gflohr)|โ
|โ
|
โ|
|๐ช๐ธ es|Spanish |[jpablom](https://github.com/jpablom)|โ|โ|โ|
|๐ซ๐ท fr|French |[monlouisj](https://github.com/monlouisj)
[Telokis](https://github.com/Telokis)|โ
|โ
|
โ|
|๐ญ๐บ hu|Hungarian|[szilveszter9](https://github.com/szilveszter9)|โ|-|-|
|๐ฎ๐ฉ id|Indonesian|[Eko Eryanto](https://github.com/ekoeryanto)|โ|โ|โ|
|๐ฎ๐น it|Italian |[jasoniangreen](https://github.com/jasoniangreen)
[lucacorti](https://github.com/lucacorti)|โ
|
โ|
โ|
|๐ฏ๐ต ja|Japanese |[gilgongo](https://github.com/gilgongo)|โ|-|-|
|๐ฐ๐ท ko|Korean |[MinByeongDon](https://github.com/MinByeongDon)|โ|โ|โ|
|๐ณ๐ด nb|Norwegian bokmรฅl|[mtramm](https://github.com/mtramm)|โ|โ|-|
|๐ณ๐ฑ nl|Dutch |[pimlie](https://github.com/pimlie)
[niekvb](https://github.com/niekvb)|โ|โ|โ|
|๐ต๐ฑ pl|Polish |[danielzurawski](https://github.com/danielzurawski)|โ|-|-|
|๐ง๐ท pt-BR|Portuguรชs - Brasil|[marcosrava](https://github.com/marcosrava)
[ggondim](https://github.com/ggondim)|โ|โ|โ|
|๐ท๐บ ru|Russian | |โ|โ|โ|
|๐ธ๐ฐ sk|Slovak |[kiskovacs](https://github.com/kiskovacs)|โ|โ|-|
|๐ธ๐ช sv|Swedish |[limmen](https://github.com/Limmen)|โ|โ|-|
|๐น๐ญ th|Thai |[encX](https://github.com/encX)|โ|โ|โ|
|๐จ๐ณ zh|Chinese |[jinzhubaofu](https://github.com/jinzhubaofu)
[leuction](https://github.com/leuction)|โ
|
โ|
โ|
|๐น๐ผ zh-TW|Chinese - Taiwan|[minipai](https://github.com/minipai)|โ|โ|โ|
\* added boolean schema, keywords `const`, `contains`, `propertyNames`
\*\* added keywords `if`/`then`/`else`
Please contribute locales that you need to use if they are missing or incomplete.
## Install
Using npm:
```
npm install ajv-i18n
```
Using bower:
```
bower install ajv-i18n
cd bower_components/ajv-i18n
npm install && npm run bundle-all
```
## Usage
In node:
```javascript
var Ajv = require('ajv'); // version >= 2.0.0
var localize = require('ajv-i18n');
// option `i18n` is required for this package to work
var ajv = Ajv({ allErrors: true });
var validate = ajv.compile(schema);
var valid = validate(data);
if (!valid) {
// ru for Russian
localize.ru(validate.errors);
// string with all errors and data paths
console.log(ajv.errorsText(validate.errors, { separator: '\n' }));
}
```
To require only necessary locales in browser (with browserify):
```javascript
var localize_ru = require('ajv-i18n/localize/ru');
```
or
```javascript
var localize = {
en: require('ajv-i18n/localize/en'),
ru: require('ajv-i18n/localize/ru')
};
```
See [Ajv docs](https://github.com/epoberezkin/ajv) for more information.
## Tests
```
npm install
git submodule update --init
npm test
```
## Contributing
Functions that localize error messages are generated using doT templates in [messages](https://github.com/epoberezkin/ajv-i18n/tree/master/messages/index.js) and [localize.jst](https://github.com/epoberezkin/ajv-i18n/tree/master/localize/localize.jst) template. Templates are precompiled so doT is not a run-time dependency.
`npm run build` - compiles functions to [localize](https://github.com/epoberezkin/ajv/tree/master/localize) folder.
## Contributors of locales
[](https://github.com/danielzurawski "danielzurawski")
[](https://github.com/szilveszter9 "szilveszter9")
[](https://github.com/jmtoball "jmtoball")
[](https://github.com/gilgongo "gilgongo")
[](https://github.com/jasoniangreen "jasoniangreen")
[](https://github.com/jpablom "jpablom")
[](https://github.com/Limmen "Limmen")
[](https://github.com/jinzhubaofu "jinzhubaofu")
[](https://github.com/kiskovacs "kiskovacs")
[](https://github.com/Mahmoud-Mardeni "mahmoud-mardeni")
[](https://github.com/monlouisj "monlouisj")
[](https://github.com/marcosrava "marcosrava")
[](https://github.com/mtramm "mtramm")
[](https://github.com/Mahmoud-Mardeni "Mahmoud-Mardeni")
[](https://github.com/leuction "leuction")
[](https://github.com/lucacorti "lucacorti")
[](https://github.com/minipai "minipai")
[](https://github.com/encX "encX")
[
](https://github.com/pimlie "pimlie")
[](https://github.com/MinByeongDon "MinByeongDon")
[](https://github.com/gflohr "gflohr")
[](https://github.com/ekoeryanto "ekoeryanto")
[](https://github.com/Telokis "Telokis")
[
](https://github.com/alexandreec "alexandreec")
[](https://github.com/ggondim "ggondim")
[](https://github.com/niekvb "niekvb")
[](https://github.com/NAM0007 "NAM0007")
## Enterprise support
ajv-i18n package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-ajv-i18n?utm_source=npm-ajv-i18n&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.
## Security contact
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.
## License
[MIT](https://github.com/epoberezkin/ajv-i18n/blob/master/LICENSE)