Refactor to ES5 code. Some updates in the docs
This commit is contained in:
parent
6f4729885b
commit
9fb29a644d
|
@ -3,8 +3,9 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet released, version 5.13.4
|
||||
## not yet released, version 5.14.0
|
||||
|
||||
- Implemented support for translations. Thanks @mariohmol.
|
||||
- Fixed a bug sometimes occurring when dragging items from array to
|
||||
object, see #509. Thanks @43081j.
|
||||
- Fixed autocomplete not accepting returned `null` values, see #512.
|
||||
|
|
10
docs/api.md
10
docs/api.md
|
@ -125,7 +125,7 @@ Constructs a new JSONEditor.
|
|||
|
||||
The following example allow you can create a "Person" node and a "Address" node, each one will appear in your context menu, once you selected the whole json object will be created.
|
||||
|
||||
```js
|
||||
```js
|
||||
var options = {
|
||||
templates: [
|
||||
{
|
||||
|
@ -192,12 +192,12 @@ Constructs a new JSONEditor.
|
|||
|
||||
Adds status bar to the buttom of the editor - the status bar shows the cursor position and a count of the selected charcters. True by default. Only applicable when `mode` is 'code' or 'text'.
|
||||
|
||||
- `{string} language`
|
||||
- `{string} language`
|
||||
|
||||
The default language comes from the browser navigator, but you can force a specific language. So use here string as 'en' or 'pt-BR'.
|
||||
The default language comes from the browser navigator, but you can force a specific language. So use here string as 'en' or 'pt-BR'. Built-in languages: `en`, `pt-BR`. Other translations can be specified via the option `languages`.
|
||||
|
||||
|
||||
- `{Object} languages`
|
||||
- `{Object} languages`
|
||||
|
||||
You can override existing translations or provide a new translation for a specific language. To do it provide an object at languages with language and the keys/values to be inserted. For example:
|
||||
|
||||
|
@ -212,6 +212,8 @@ Constructs a new JSONEditor.
|
|||
}
|
||||
```
|
||||
|
||||
All available fields for translation can be found in the source file `src/js/i18n.js`.
|
||||
|
||||
|
||||
### Methods
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>JSONEditor | Basic usage</title>
|
||||
<title>JSONEditor | Translate</title>
|
||||
|
||||
<link href="../dist/jsoneditor.css" rel="stylesheet" type="text/css">
|
||||
<script src="../dist/jsoneditor.js"></script>
|
||||
<script src="../dist/jsoneditor.min.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#jsoneditor {
|
||||
|
@ -16,6 +16,9 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<p>
|
||||
JSONEditor has support for multiple languages (i18n), in this case uses <code>pt-BR</code>.
|
||||
</p>
|
||||
<p>
|
||||
<button id="setJSON">Set JSON</button>
|
||||
<button id="getJSON">Get JSON</button>
|
||||
|
@ -28,7 +31,7 @@
|
|||
var options = {
|
||||
// switch between pt-BR or en for testing forcing a language
|
||||
// leave blank to get language
|
||||
'language': 'en',
|
||||
'language': 'pt-BR',
|
||||
'languages': {
|
||||
'pt-BR': {
|
||||
'auto': 'Automático testing'
|
||||
|
|
|
@ -105,7 +105,9 @@ var _defs = {
|
|||
var _defaultLang = 'en';
|
||||
var _lang;
|
||||
var userLang = navigator.language || navigator.userLanguage;
|
||||
_lang = _locales.find(l => l === userLang);
|
||||
_lang = _locales.find(function (l) {
|
||||
return l === userLang;
|
||||
});
|
||||
if (!_lang) {
|
||||
_lang = _defaultLang;
|
||||
}
|
||||
|
@ -115,11 +117,13 @@ module.exports = {
|
|||
_locales: _locales,
|
||||
_defs: _defs,
|
||||
_lang: _lang,
|
||||
setLanguage(lang) {
|
||||
setLanguage: function (lang) {
|
||||
if (!lang) {
|
||||
return;
|
||||
}
|
||||
var langFound = _locales.find(l => l === lang);
|
||||
var langFound = _locales.find(function (l) {
|
||||
return l === lang;
|
||||
});
|
||||
if (langFound) {
|
||||
_lang = langFound;
|
||||
} else {
|
||||
|
@ -131,7 +135,9 @@ module.exports = {
|
|||
return;
|
||||
}
|
||||
for (var key in languages) {
|
||||
var langFound = _locales.find(l => l === key);
|
||||
var langFound = _locales.find(function (l) {
|
||||
return l === key;
|
||||
});
|
||||
if (!langFound) {
|
||||
_locales.push(key);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ var Node = require('./Node');
|
|||
var ModeSwitcher = require('./ModeSwitcher');
|
||||
var util = require('./util');
|
||||
var autocomplete = require('./autocomplete');
|
||||
var { translate, setLanguages, setLanguage} = require('./i18n');
|
||||
var translate = require('./i18n').translate;
|
||||
var setLanguages = require('./i18n').setLanguages;
|
||||
var setLanguage = require('./i18n').setLanguage;
|
||||
|
||||
// create a mixin with the functions for tree mode
|
||||
var treemode = {};
|
||||
|
|
Loading…
Reference in New Issue