# ajv-i18n Internationalised error messages for [Ajv](https://github.com/epoberezkin/ajv) - currently the fastest JSON-Schema validator [![Build Status](https://travis-ci.org/ajv-validator/ajv-i18n.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv-i18n) [![npm](https://img.shields.io/npm/v/ajv-i18n.svg)](https://www.npmjs.com/package/ajv-i18n) [![Coverage Status](https://coveralls.io/repos/github/ajv-validator/ajv-i18n/badge.svg?branch=master)](https://coveralls.io/github/ajv-validator/ajv-i18n?branch=master) [![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](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 [![danielzurawski](https://avatars3.githubusercontent.com/u/1625711?v=3&s=40)](https://github.com/danielzurawski "danielzurawski") [![szilveszter9](https://avatars0.githubusercontent.com/u/7540866?v=3&s=40)](https://github.com/szilveszter9 "szilveszter9") [![jmtoball](https://avatars0.githubusercontent.com/u/219950?v=3&s=40)](https://github.com/jmtoball "jmtoball") [![gilgongo](https://avatars2.githubusercontent.com/u/4561747?v=3&s=40)](https://github.com/gilgongo "gilgongo") [![jasoniangreen](https://avatars3.githubusercontent.com/u/3481367?v=3&s=40)](https://github.com/jasoniangreen "jasoniangreen") [![jpablom](https://avatars0.githubusercontent.com/u/3935083?v=3&s=40)](https://github.com/jpablom "jpablom") [![limmen](https://avatars2.githubusercontent.com/u/8254791?v=3&s=40)](https://github.com/Limmen "Limmen") [![jinzhubaofu](https://avatars2.githubusercontent.com/u/811195?v=3&s=40)](https://github.com/jinzhubaofu "jinzhubaofu") [![kiskovacs](https://avatars1.githubusercontent.com/u/2733311?v=3&s=40)](https://github.com/kiskovacs "kiskovacs") [![mahmoud-mardeni](https://avatars2.githubusercontent.com/u/19661270?s=40&v=3)](https://github.com/Mahmoud-Mardeni "mahmoud-mardeni") [![monlouisj](https://avatars0.githubusercontent.com/u/5998380?v=3&s=40)](https://github.com/monlouisj "monlouisj") [![marcosrava](https://avatars2.githubusercontent.com/u/243790?v=3&s=40)](https://github.com/marcosrava "marcosrava") [![mtramm](https://avatars3.githubusercontent.com/u/3519541?v=3&s=40)](https://github.com/mtramm "mtramm") [![Mahmoud-Mardeni](https://avatars3.githubusercontent.com/u/19661270?v=3&s=40)](https://github.com/Mahmoud-Mardeni "Mahmoud-Mardeni") [![leuction](https://avatars3.githubusercontent.com/u/8056270?v=3&s=40)](https://github.com/leuction "leuction") [![lucacorti](https://avatars2.githubusercontent.com/u/1076999?v=3&s=40)](https://github.com/lucacorti "lucacorti") [![minipai](https://avatars2.githubusercontent.com/u/239570?s=40&v=4)](https://github.com/minipai "minipai") [![encX](https://avatars3.githubusercontent.com/u/5965883?v=3&s=40)](https://github.com/encX "encX") [pimlie](https://github.com/pimlie "pimlie") [![MinByeongDon](https://avatars2.githubusercontent.com/u/6141807?s=40&v=4)](https://github.com/MinByeongDon "MinByeongDon") [![gflohr](https://avatars0.githubusercontent.com/u/7126580?s=40&v=4)](https://github.com/gflohr "gflohr") [![ekoeryanto](https://avatars2.githubusercontent.com/u/36023898?s=40&v=4)](https://github.com/ekoeryanto "ekoeryanto") [![Telokis](https://avatars3.githubusercontent.com/u/6382729?s=40&v=4)](https://github.com/Telokis "Telokis") [alexandreec](https://github.com/alexandreec "alexandreec") [![ggondim](https://avatars2.githubusercontent.com/u/2074685?s=40&v=4)](https://github.com/ggondim "ggondim") [![niekvb](https://avatars3.githubusercontent.com/u/37668320?s=40&v=4)](https://github.com/niekvb "niekvb") [![NAM0007](https://avatars1.githubusercontent.com/u/47188486?s=40&v=4)](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)