Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"ajv": "3.4.0",
"ajv-i18n": "1.0.0",
"brace": "0.7.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/JSONEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function JSONEditor (container, options, json) {
'ace', 'theme',
'ajv', 'schema',
'onChange', 'onEditable', 'onError', 'onModeChange',
'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation'
'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation', 'lang'
];

Object.keys(options).forEach(function (option) {
Expand Down
9 changes: 9 additions & 0 deletions src/js/textmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ catch (err) {
// failed to load ace, no problem, we will fall back to plain text
}

var localize = require('ajv-i18n');
var modeswitcher = require('./modeswitcher');
var util = require('./util');

Expand Down Expand Up @@ -409,6 +410,7 @@ textmode.validate = function () {
if (doValidate && this.validateSchema) {
var valid = this.validateSchema(json);
if (!valid) {
this._translate(this.validateSchema.errors);
errors = this.validateSchema.errors.map(function (error) {
return util.improveSchemaError(error);
});
Expand Down Expand Up @@ -457,6 +459,13 @@ textmode.validate = function () {
}
};

textmode._translate = function(errors) {
var fn = localize[this.options.lang];
if (fn !== undefined && fn !== null) {
fn(errors);
}
};

// define modes
module.exports = [
{
Expand Down
9 changes: 9 additions & 0 deletions src/js/treemode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var localize = require('ajv-i18n')
var Highlighter = require('./Highlighter');
var History = require('./History');
var SearchBox = require('./SearchBox');
Expand Down Expand Up @@ -373,6 +374,7 @@ treemode.validate = function () {
var valid = this.validateSchema(root.getValue());
if (!valid) {
// apply all new errors
this._translate(this.validateSchema.errors);
schemaErrors = this.validateSchema.errors
.map(function (error) {
return util.improveSchemaError(error);
Expand Down Expand Up @@ -417,6 +419,13 @@ treemode.validate = function () {
});
};

treemode._translate = function(errors) {
var fn = localize[this.options.lang];
if (fn !== undefined && fn !== null) {
fn(errors);
}
};

/**
* Start autoscrolling when given mouse position is above the top of the
* editor contents, or below the bottom.
Expand Down