From 924ca1afc376a640dba031283a4dc3fcc9305db0 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Sat, 4 Jan 2020 15:05:42 +0100 Subject: [PATCH] Fix #873: buttons Format, Compact, and Repair not supporting internationalization --- HISTORY.md | 6 ++++++ src/js/i18n.js | 27 +++++++++++++++------------ src/js/previewmode.js | 6 +++--- src/js/textmode.js | 6 +++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 3c69eb8..818b2f0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,12 @@ https://github.com/josdejong/jsoneditor +## not yet published, version 8.1.2 + +- Fix #873: buttons Format, Compact, and Repair not supporting + internationalization. + + ## 2019-12-28, version 8.1.1 - Fixed the file size reported in `preview` mode show `KB` and `MB` instead diff --git a/src/js/i18n.js b/src/js/i18n.js index c946eef..12303db 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -16,7 +16,10 @@ const _defs = { ascending: 'Ascending', ascendingTitle: 'Sort the childs of this ${type} in ascending order', actionsMenu: 'Click to open the actions menu (Ctrl+M)', + cannotParseFieldError: 'Cannot parse field into JSON', + cannotParseValueError: 'Cannot parse value into JSON', collapseAll: 'Collapse all fields', + compactTitle: 'Compact JSON data, remove all whitespaces (Ctrl+Shift+\\)', descending: 'Descending', descendingTitle: 'Sort the childs of this ${type} in descending order', drag: 'Drag to move this field (Alt+Shift+Arrows)', @@ -25,12 +28,11 @@ const _defs = { duplicateTitle: 'Duplicate selected fields (Ctrl+D)', duplicateField: 'Duplicate this field (Ctrl+D)', duplicateFieldError: 'Duplicate field name', - cannotParseFieldError: 'Cannot parse field into JSON', - cannotParseValueError: 'Cannot parse value into JSON', empty: 'empty', expandAll: 'Expand all fields', expandTitle: 'Click to expand/collapse this field (Ctrl+E). \n' + 'Ctrl+Click to expand/collapse including all childs.', + formatTitle: 'Format JSON data, with proper indentation and line feeds (Ctrl+\\)', insert: 'Insert', insertTitle: 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)', insertSub: 'Select the type of the field to be inserted', @@ -40,6 +42,7 @@ const _defs = { removeText: 'Remove', removeTitle: 'Remove selected fields (Ctrl+Del)', removeField: 'Remove this field (Ctrl+Del)', + repairTitle: 'Repair JSON: fix quotes and escape characters, remove comments and JSONP notation, turn JavaScript objects into JSON.', searchTitle: 'Search fields and values', searchNextResultTitle: 'Next result (Enter)', searchPreviousResultTitle: 'Previous result (Shift + Enter)', @@ -111,7 +114,10 @@ const _defs = { ascending: '升序', ascendingTitle: '升序排列${type}的子节点', actionsMenu: '点击打开动作菜单(Ctrl+M)', + cannotParseFieldError: '无法将字段解析为JSON', + cannotParseValueError: '无法将值解析为JSON', collapseAll: '缩进所有字段', + compactTitle: '压缩JSON数据,删除所有空格 (Ctrl+Shift+\\)', descending: '降序', descendingTitle: '降序排列${type}的子节点', drag: '拖拽移动该节点(Alt+Shift+Arrows)', @@ -120,12 +126,11 @@ const _defs = { duplicateTitle: '复制选中字段(Ctrl+D)', duplicateField: '复制该字段(Ctrl+D)', duplicateFieldError: '重复的字段名称', - cannotParseFieldError: '无法将字段解析为JSON', - cannotParseValueError: '无法将值解析为JSON', empty: '清空', expandAll: '展开所有字段', expandTitle: '点击 展开/收缩 该字段(Ctrl+E). \n' + 'Ctrl+Click 展开/收缩 包含所有子节点.', + formatTitle: '使用适当的缩进和换行符格式化JSON数据 (Ctrl+\\)', insert: '插入', insertTitle: '在此字段前插入类型为“auto”的新字段 (Ctrl+Ins)', insertSub: '选择要插入的字段类型', @@ -135,6 +140,7 @@ const _defs = { removeText: '移除', removeTitle: '移除选中字段 (Ctrl+Del)', removeField: '移除该字段 (Ctrl+Del)', + repairTitle: '修复JSON:修复引号和转义符,删除注释和JSONP表示法,将JavaScript对象转换为JSON。', selectNode: '选择一个节点...', showAll: '展示全部', showMore: '展示更多', @@ -202,7 +208,10 @@ const _defs = { ascending: 'Ascendente', ascendingTitle: 'Organizar filhor do tipo ${type} em crescente', actionsMenu: 'Clique para abrir o menu de ações (Ctrl+M)', + cannotParseFieldError: 'Não é possível analisar o campo no JSON', + cannotParseValueError: 'Não é possível analisar o valor em JSON', collapseAll: 'Fechar todos campos', + compactTitle: 'Dados JSON compactos, remova todos os espaços em branco (Ctrl+Shift+\\)', descending: 'Descendente', descendingTitle: 'Organizar o filhos do tipo ${type} em decrescente', duplicateKey: 'chave duplicada', @@ -211,12 +220,11 @@ const _defs = { duplicateTitle: 'Duplicar campos selecionados (Ctrl+D)', duplicateField: 'Duplicar este campo (Ctrl+D)', duplicateFieldError: 'Nome do campo duplicado', - cannotParseFieldError: 'Não é possível analisar o campo no JSON', - cannotParseValueError: 'Não é possível analisar o valor em JSON', empty: 'vazio', expandAll: 'Expandir todos campos', expandTitle: 'Clique para expandir/encolher este campo (Ctrl+E). \n' + 'Ctrl+Click para expandir/encolher incluindo todos os filhos.', + formatTitle: 'Formate dados JSON, com recuo e feeds de linha adequados (Ctrl+\\)', insert: 'Inserir', insertTitle: 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)', insertSub: 'Selecionar o tipo de campo a ser inserido', @@ -226,15 +234,13 @@ const _defs = { removeText: 'Remover', removeTitle: 'Remover campos selecionados (Ctrl+Del)', removeField: 'Remover este campo (Ctrl+Del)', - // TODO: correctly translate + repairTitle: 'Repare JSON: corrija aspas e caracteres de escape, remova comentários e notação JSONP, transforme objetos JavaScript em JSON.', selectNode: 'Selecione um nódulo...', showAll: 'mostrar todos', showMore: 'mostrar mais', - // TODO: correctly translate showMoreStatus: 'exibindo ${visibleChilds} de ${totalChilds} itens.', sort: 'Organizar', sortTitle: 'Organizar os filhos deste ${type}', - // TODO: correctly translate sortTitleShort: 'Organizar os filhos', sortFieldLabel: 'Campo:', sortDirectionLabel: 'Direção:', @@ -244,13 +250,10 @@ const _defs = { sortDescending: 'Descendente', sortDescendingTitle: 'Ordenar o campo selecionado por ordem descendente', string: 'Texto', - // TODO: correctly translate transform: 'Transformar', transformTitle: 'Filtrar, ordenar ou transformar os filhos deste ${type}', transformTitleShort: 'Filtrar, ordenar ou transformar conteúdos', - // TODO: correctly translate transformQueryTitle: 'Insira uma expressão JMESPath', - // TODO: correctly translate transformWizardLabel: 'Assistente', transformWizardFilter: 'Filtro', transformWizardSortBy: 'Ordenar por', diff --git a/src/js/previewmode.js b/src/js/previewmode.js index e61d02d..dd74985 100644 --- a/src/js/previewmode.js +++ b/src/js/previewmode.js @@ -116,7 +116,7 @@ previewmode.create = function (container, options = {}) { const buttonFormat = document.createElement('button') buttonFormat.type = 'button' buttonFormat.className = 'jsoneditor-format' - buttonFormat.title = 'Format JSON data, with proper indentation and line feeds (Ctrl+\\)' + buttonFormat.title = translate('formatTitle') this.menu.appendChild(buttonFormat) buttonFormat.onclick = function handleFormat () { me.executeWithBusyMessage(() => { @@ -132,7 +132,7 @@ previewmode.create = function (container, options = {}) { const buttonCompact = document.createElement('button') buttonCompact.type = 'button' buttonCompact.className = 'jsoneditor-compact' - buttonCompact.title = 'Compact JSON data, remove all whitespaces (Ctrl+Shift+\\)' + buttonCompact.title = translate('compactTitle') this.menu.appendChild(buttonCompact) buttonCompact.onclick = function handleCompact () { me.executeWithBusyMessage(() => { @@ -173,7 +173,7 @@ previewmode.create = function (container, options = {}) { const buttonRepair = document.createElement('button') buttonRepair.type = 'button' buttonRepair.className = 'jsoneditor-repair' - buttonRepair.title = 'Repair JSON: fix quotes and escape characters, remove comments and JSONP notation, turn JavaScript objects into JSON.' + buttonRepair.title = translate('repairTitle') this.menu.appendChild(buttonRepair) buttonRepair.onclick = () => { if (me.json === undefined) { // only repair if we don't have valid JSON diff --git a/src/js/textmode.js b/src/js/textmode.js index b507c4b..195d966 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -129,7 +129,7 @@ textmode.create = function (container, options = {}) { const buttonFormat = document.createElement('button') buttonFormat.type = 'button' buttonFormat.className = 'jsoneditor-format' - buttonFormat.title = 'Format JSON data, with proper indentation and line feeds (Ctrl+\\)' + buttonFormat.title = translate('formatTitle') this.menu.appendChild(buttonFormat) buttonFormat.onclick = () => { try { @@ -144,7 +144,7 @@ textmode.create = function (container, options = {}) { const buttonCompact = document.createElement('button') buttonCompact.type = 'button' buttonCompact.className = 'jsoneditor-compact' - buttonCompact.title = 'Compact JSON data, remove all whitespaces (Ctrl+Shift+\\)' + buttonCompact.title = translate('compactTitle') this.menu.appendChild(buttonCompact) buttonCompact.onclick = () => { try { @@ -183,7 +183,7 @@ textmode.create = function (container, options = {}) { const buttonRepair = document.createElement('button') buttonRepair.type = 'button' buttonRepair.className = 'jsoneditor-repair' - buttonRepair.title = 'Repair JSON: fix quotes and escape characters, remove comments and JSONP notation, turn JavaScript objects into JSON.' + buttonRepair.title = translate('repairTitle') this.menu.appendChild(buttonRepair) buttonRepair.onclick = () => { try {