Skip to content

Commit

Permalink
Merge ae77da1 into 906ebba
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Mar 10, 2021
2 parents 906ebba + ae77da1 commit edc83d4
Show file tree
Hide file tree
Showing 21 changed files with 1,031 additions and 1,037 deletions.
48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const jsConfig = require("@ajv-validator/config/.eslintrc_js")

module.exports = {
env: {
es6: true,
node: true,
},
overrides: [
{
...jsConfig,
rules: {
semi: [2, "never"],
},
},
],
}

// extends: eslint:recommended
// env:
// node: true
// browser: true
// parserOptions:
// ecmaVersion: 2018
// rules:
// block-scoped-var: 2
// callback-return: 2
// curly: [2, multi-or-nest, consistent]
// dot-location: [2, property]
// dot-notation: 2
// indent-legacy: [2, 2, SwitchCase: 1]
// linebreak-style: [2, unix]
// new-cap: 2
// no-console: [2, allow: [warn, error]]
// no-else-return: 2
// no-eq-null: 2
// no-fallthrough: 2
// no-invalid-this: 2
// no-return-assign: 2
// no-shadow: 1
// no-trailing-spaces: 2
// no-use-before-define: [2, nofunc]
// quotes: [2, single, avoid-escape]
// semi: [2, always]
// strict: [2, global]
// valid-jsdoc: [2, requireReturn: false]
// no-control-regex: 0
// no-useless-escape: 2
// no-tabs: 2
30 changes: 0 additions & 30 deletions .eslintrc.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: build

on:
push:
branches: [master]
pull_request:
branches: ["*"]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: git submodule update --init
- run: npm test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: publish

on:
release:
types: [published]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm install
- run: git submodule update --init
- run: npm test
- name: Publish beta version to npm
if: "github.event.release.prerelease"
run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
if: "!github.event.release.prerelease"
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
url = https://github.com/json-schema/JSON-Schema-Test-Suite.git
[submodule "spec/ajv-keywords"]
path = spec/ajv-keywords
url = https://github.com/epoberezkin/ajv-keywords.git
url = https://github.com/ajv-validator/ajv-keywords.git
[submodule "spec/ajv-formats"]
path = spec/ajv-formats
url = https://github.com/ajv-validator/ajv-formats
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spec/JSON-Schema-Test-Suite
spec/ajv-keywords
.browser
coverage
bundle
.nyc_output
localize
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@ Internationalised error messages for [Ajv](https://github.com/epoberezkin/ajv) -

## Supported locales

|locale|language |contributor|draft-04|draft-06<sup>\*</sup>|draft-07<sup>\*\*</sup>|
|------|:-------:|:---------:|:------:|:------:|:------:|
|🇬🇧 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)<br>[NAM0007](https://github.com/NAM0007)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|
|🇩🇪 de|German |[jmtoball](https://github.com/jmtoball)<br>[gflohr](https://github.com/gflohr)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|
|🇪🇸 es|Spanish |[jpablom](https://github.com/jpablom)||||
|🇫🇷 fr|French |[monlouisj](https://github.com/monlouisj)<br>[Telokis](https://github.com/Telokis)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|
|🇭🇺 hu|Hungarian|[szilveszter9](https://github.com/szilveszter9)||-|-|
|🇮🇩 id|Indonesian|[Eko Eryanto](https://github.com/ekoeryanto)||||
|🇮🇹 it|Italian |[jasoniangreen](https://github.com/jasoniangreen)<br>[lucacorti](https://github.com/lucacorti)|✓<br>&nbsp;|<br>✓|<br>✓|
|🇯🇵 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)<br>[niekvb](https://github.com/niekvb)||||
|🇵🇱 pl|Polish |[danielzurawski](https://github.com/danielzurawski)||-|-|
|🇧🇷 pt-BR|Português - Brasil|[marcosrava](https://github.com/marcosrava)<br>[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)<br>[leuction](https://github.com/leuction)|✓<br>&nbsp;|<br>✓|<br>✓|
|🇹🇼 zh-TW|Chinese - Taiwan|[minipai](https://github.com/minipai)||||


<sup>\*</sup> added boolean schema, keywords `const`, `contains`, `propertyNames`

<sup>\*\*</sup> added keywords `if`/`then`/`else`
|locale|language |contributor|draft-04|draft-06<sup>1</sup>|draft-07<sup>2</sup>|draft<br>2019-09<br>2020-12<sup>3</sup>|
|------|:-------:|:---------:|:------:|:------:|:------:|:------:|
|🇬🇧 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)<br>[NAM0007](https://github.com/NAM0007)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|-|
|🇩🇪 de|German |[jmtoball](https://github.com/jmtoball)<br>[gflohr](https://github.com/gflohr)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|-|
|🇪🇸 es|Spanish |[jpablom](https://github.com/jpablom)||||-|
|🇫🇷 fr|French |[monlouisj](https://github.com/monlouisj)<br>[Telokis](https://github.com/Telokis)|✓<br>&nbsp;|✓<br>&nbsp;|<br>✓|-|
|🇭🇺 hu|Hungarian|[szilveszter9](https://github.com/szilveszter9)||-|-|-|
|🇮🇩 id|Indonesian|[Eko Eryanto](https://github.com/ekoeryanto)||||-|
|🇮🇹 it|Italian |[jasoniangreen](https://github.com/jasoniangreen)<br>[lucacorti](https://github.com/lucacorti)|✓<br>&nbsp;|<br>✓|<br>✓|-|
|🇯🇵 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)<br>[niekvb](https://github.com/niekvb)||||-|
|🇵🇱 pl|Polish |[danielzurawski](https://github.com/danielzurawski)||-|-|-|
|🇧🇷 pt-BR|Português - Brasil|[marcosrava](https://github.com/marcosrava)<br>[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)<br>[leuction](https://github.com/leuction)|✓<br>&nbsp;|<br>✓|<br>✓|-|
|🇹🇼 zh-TW|Chinese - Taiwan|[minipai](https://github.com/minipai)||||-|


<sup>1</sup> added boolean schema, keywords `const`, `contains`, `propertyNames`

<sup>2</sup> added keywords `if`/`then`/`else`

<sup>3</sup> added keywords `unevaluatedProperties`, `unevaluatedItems`, `dependentRequired`

Please contribute locales that you need to use if they are missing or incomplete.

Expand Down
24 changes: 4 additions & 20 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@
"name": "ajv-i18n",
"description": "Internationalised error messages for avj JSON-Schema Validator",
"main": "dist/ajv-i18n.min.js",
"authors": [
"Evgeny Poberezkin"
],
"authors": ["Evgeny Poberezkin"],
"license": "MIT",
"keywords": [
"ajv",
"JSON",
"schema",
"i18n",
"internationalisation"
],
"keywords": ["ajv", "JSON", "schema", "i18n", "internationalisation"],
"homepage": "https://github.com/epoberezkin/ajv-i18n",
"moduleType": [
"amd",
"globals",
"node"
],
"ignore": [
"node_modules",
"bower_components",
"spec"
]
"moduleType": ["amd", "globals", "node"],
"ignore": ["node_modules", "bower_components", "spec"]
}
27 changes: 7 additions & 20 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,44 @@
// Karma configuration
// Generated on Fri Feb 26 2016 16:59:16 GMT+0900 (JST)

module.exports = function(config) {
module.exports = function (config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

basePath: "",

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],

frameworks: ["mocha"],

// list of files / patterns to load in the browser
files: [
'dist/ajv-i18n.test.min.js',
'.browser/*.spec.js'
],

files: ["dist/ajv-i18n.test.min.js", ".browser/*.spec.js"],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots'],

reporters: ["dots"],

// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],

browsers: ["Chrome"],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

browserNoActivityTimeout: 90000
browserNoActivityTimeout: 90000,
})
}
3 changes: 3 additions & 0 deletions localize/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules:
semi: [2, always]
no-redeclare: 0
17 changes: 10 additions & 7 deletions localize/localize.jst
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
'use strict';

{{
var STRIP_FUNCTION = /function\s+anonymous\s*\(it[^)]*\)\s*{|return\s+out;\s*}/g
, VAR_OUT = /var\s+out/
, OUT_EMPTY_STRING = /out\s*\+=\s*\'\'\s*\+\s*/g;
const STRIP_FUNCTION = /function\s+anonymous\s*\(it[^)]*\)\s*{|return\s+out;\s*}/g;
const VAR_OUT = /var\s+out/;
const OUT_EMPTY_STRING = /out\s*\+=\s*\'\'\s*\+\s*/g;
}}

{{ var name = 'localize_' + it.locale.replace('-','_'); }}
module.exports = function {{=name}}(errors) {
if (!(errors && errors.length)) return;
for (var i=0; i<errors.length; i++) {
var e = errors[i];
var out;
for (const e of errors) {
let out;
switch (e.keyword) {
{{~ it.messages:msg }}
case '{{= msg.keyword }}':
{{~ msg.keywords:kwd }}
case '{{= kwd }}':
{{~}}
{{= stripFunction(msg.msgFunc) }}
break;
{{~}}
default: continue;
default:
{{= stripFunction(it.defaultMessage) }}
}
e.message = out;
}
Expand Down
Loading

0 comments on commit edc83d4

Please sign in to comment.