jdorn/json-editor — pull request #155 by SebT (2014-06-25 16:32:24+00:00)
Title: String customization

This allows the developers to customize strings that are supposed to be displayed to the end-user (i.e the user filling the form on his browser).

To to so, the user passes a `textCallback` to the JSONEditor constructor that will be called with two parameters:
+ `key`: The id of the message to display
+ (optional) `variables`: An array of string (explained bellow)

The callback is supposed to return the string to display.
If the callback is undefined or returns undefined/null, the default text for the given key will be used.

Default messages are stored in the object `JSONEditor.defaults.text` in `default.js`. Every key is documented to inform the user how the `variables`array will be populated.

*Example use:*
```js
new JSONEditor(document.body, {
schema: {
type: "object",
properties: {
test: {
type: "string",
maxLength: 10,
minLength: 1
}
}
},
// With this callback, the default messages will always be displayed, except when the error concerns
// a string's min length
textCallback: function(key, variables) {
// By reading defaults.js, I know that variables[0] is the number of minimum characters for the value
// to validate the schema
if(key === "error_minLength") return "Minimum characters: " + variables[0]";
return undefined
}
})
```

This is a pretty simple string customization but it is better than nothing. This allows developers to translate keys and customize them.

Later we could provide several default key sets based on languages, and provide the title of the schema path that failed being validated for further customization.