From 8dff972dce86df0fd45d05190005b0a828faeda1 Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 12 May 2018 16:53:18 +0200 Subject: [PATCH] Implemented translate (`pt-BR` still has to be checked for correctness) --- src/css/jsoneditor.css | 1 + src/js/i18n.js | 9 +++++++++ src/js/showMoreNodeFactory.js | 12 ++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/css/jsoneditor.css b/src/css/jsoneditor.css index f2cf646..e770a81 100644 --- a/src/css/jsoneditor.css +++ b/src/css/jsoneditor.css @@ -190,6 +190,7 @@ div.jsoneditor-tree div.jsoneditor-show-more { } div.jsoneditor-tree div.jsoneditor-show-more a { + display: inline-block; color: #808080; } diff --git a/src/js/i18n.js b/src/js/i18n.js index 26fb437..5199047 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -32,6 +32,9 @@ var _defs = { 'removeText': 'Remove', 'removeTitle': 'Remove selected fields (Ctrl+Del)', 'removeField': 'Remove this field (Ctrl+Del)', + 'showAll': 'show all', + 'showMore': 'show more', + 'showMoreStatus': 'displaying ${maxVisibleChilds} of ${totalChilds} items.', 'sort': 'Sort', 'sortTitle': 'Sort the childs of this ', 'string': 'String', @@ -81,6 +84,12 @@ var _defs = { 'removeText': 'Remover', 'removeTitle': 'Remover campos selecionados (Ctrl+Del)', 'removeField': 'Remover este campo (Ctrl+Del)', + // TODO: correctly translate showAll + 'showAll': 'mostre tudo', + // TODO: correctly translate showMore + 'showMore': 'mostre mais', + // TODO: correctly translate showMoreStatus + 'showMoreStatus': 'exibindo ${maxVisibleChilds} de ${totalChilds} itens.', 'sort': 'Organizar', 'sortTitle': 'Organizar os filhos deste ', 'string': 'Texto', diff --git a/src/js/showMoreNodeFactory.js b/src/js/showMoreNodeFactory.js index be14eef..ee8c5dd 100644 --- a/src/js/showMoreNodeFactory.js +++ b/src/js/showMoreNodeFactory.js @@ -40,7 +40,7 @@ function showMoreNodeFactory(Node) { var me = this; var parent = this.parent; var showMoreButton = document.createElement('a'); - showMoreButton.appendChild(document.createTextNode('show\u00A0more')); + showMoreButton.appendChild(document.createTextNode(translate('showMore'))); showMoreButton.href = '#'; showMoreButton.onclick = function (event) { // TODO: use callback instead of accessing a method of the parent @@ -53,7 +53,7 @@ function showMoreNodeFactory(Node) { }; var showAllButton = document.createElement('a'); - showAllButton.appendChild(document.createTextNode('show\u00A0all')); + showAllButton.appendChild(document.createTextNode(translate('showAll'))); showAllButton.href = '#'; showAllButton.onclick = function (event) { // TODO: use callback instead of accessing a method of the parent @@ -120,10 +120,10 @@ function showMoreNodeFactory(Node) { }; ShowMoreNode.prototype._getShowMoreText = function() { - // TODO: implement in translate - var childs = this.type === 'array' ? 'items' : 'properties'; - return 'displaying ' + this.parent.maxVisibleChilds + - ' of ' + this.parent.childs.length + ' ' + childs + '. '; + return translate('showMoreStatus', { + maxVisibleChilds: this.parent.maxVisibleChilds, + totalChilds: this.parent.childs.length + }) + ' '; }; /**