Skip to content
Merged
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
46 changes: 45 additions & 1 deletion src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,51 @@ JSONEditor.defaults.languages.en = {
* When a dependency is not resolved
* @variables This key takes one variable: The name of the missing property for the dependency
*/
error_dependency: "Must have property {{0}}"
error_dependency: "Must have property {{0}}",
/**
* Text on Delete All buttons
*/
button_delete_all: "All",
/**
* Title on Delete All buttons
*/
button_delete_all_title: "Delete All",
/**
* Text on Delete Last buttons
* @variable This key takes one variable: The title of object to delete
*/
button_delete_last: "Last {{0}}",
/**
* Title on Delete Last buttons
* @variable This key takes one variable: The title of object to delete
*/
button_delete_last_title: "Delete Last {{0}}",
/**
* Title on Add Row buttons
* @variable This key takes one variable: The title of object to add
*/
button_add_row_title: "Add {{0}}",
/**
* Title on Move Down buttons
*/
button_move_down_title: "Move down",
/**
* Title on Move Up buttons
*/
button_move_up_title: "Move up",
/**
* Title on Delete Row buttons
* @variable This key takes one variable: The title of object to delete
*/
button_delete_row_title: "Delete {{0}}",
/**
* Title on Delete Row buttons, short version (no parameter with the object title)
*/
button_delete_row_title_short: "Delete",
/**
* Title on Collapse buttons
*/
button_collapse: "Collapse"
};

// Miscellaneous Plugin Settings
Expand Down
2 changes: 2 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ JSONEditor.AbstractEditor = Class.extend({
this.template_engine = this.jsoneditor.template;
this.iconlib = this.jsoneditor.iconlib;

this.translate = this.jsoneditor.translate || JSONEditor.defaults.translate;

this.original_schema = options.schema;
this.schema = this.jsoneditor.expandSchema(this.original_schema);

Expand Down
14 changes: 7 additions & 7 deletions src/editors/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({

// Buttons to delete row, move row up, and move row down
if(!self.hide_delete_buttons) {
self.rows[i].delete_button = this.getButton(self.getItemTitle(),'delete','Delete '+self.getItemTitle());
self.rows[i].delete_button = this.getButton(self.getItemTitle(),'delete',this.translate('button_delete_row_title',[self.getItemTitle()]));
self.rows[i].delete_button.className += ' delete';
self.rows[i].delete_button.setAttribute('data-i',i);
self.rows[i].delete_button.addEventListener('click',function(e) {
Expand Down Expand Up @@ -499,7 +499,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
}

if(i && !self.hide_move_buttons) {
self.rows[i].moveup_button = this.getButton('','moveup','Move up');
self.rows[i].moveup_button = this.getButton('','moveup',this.translate('button_move_up_title'));
self.rows[i].moveup_button.className += ' moveup';
self.rows[i].moveup_button.setAttribute('data-i',i);
self.rows[i].moveup_button.addEventListener('click',function(e) {
Expand All @@ -526,7 +526,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
}

if(!self.hide_move_buttons) {
self.rows[i].movedown_button = this.getButton('','movedown','Move down');
self.rows[i].movedown_button = this.getButton('','movedown',this.translate('button_move_down_title'));
self.rows[i].movedown_button.className += ' movedown';
self.rows[i].movedown_button.setAttribute('data-i',i);
self.rows[i].movedown_button.addEventListener('click',function(e) {
Expand Down Expand Up @@ -558,7 +558,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
var self = this;

this.collapsed = false;
this.toggle_button = this.getButton('','collapse','Collapse');
this.toggle_button = this.getButton('','collapse',this.translate('button_collapse'));
this.title_controls.appendChild(this.toggle_button);
var row_holder_display = self.row_holder.style.display;
var controls_display = self.controls.style.display;
Expand Down Expand Up @@ -597,7 +597,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
}

// Add "new row" and "delete last" buttons below editor
this.add_row_button = this.getButton(this.getItemTitle(),'add','Add '+this.getItemTitle());
this.add_row_button = this.getButton(this.getItemTitle(),'add',this.translate('button_add_row_title',[this.getItemTitle()]));

this.add_row_button.addEventListener('click',function(e) {
e.preventDefault();
Expand All @@ -620,7 +620,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
});
self.controls.appendChild(this.add_row_button);

this.delete_last_row_button = this.getButton('Last '+this.getItemTitle(),'delete','Delete Last '+this.getItemTitle());
this.delete_last_row_button = this.getButton(this.translate('button_delete_last',[this.getItemTitle()]),'delete',this.translate('button_delete_last_title',[this.getItemTitle()]));
this.delete_last_row_button.addEventListener('click',function(e) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -639,7 +639,7 @@ JSONEditor.defaults.editors.array = JSONEditor.AbstractEditor.extend({
});
self.controls.appendChild(this.delete_last_row_button);

this.remove_all_rows_button = this.getButton('All','delete','Delete All');
this.remove_all_rows_button = this.getButton(this.translate('button_delete_all'),'delete',this.translate('button_delete_all_title'));
this.remove_all_rows_button.addEventListener('click',function(e) {
e.preventDefault();
e.stopPropagation();
Expand Down
14 changes: 7 additions & 7 deletions src/editors/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({

// Buttons to delete row, move row up, and move row down
if(!this.hide_delete_buttons) {
self.rows[i].delete_button = this.getButton('','delete','Delete');
self.rows[i].delete_button = this.getButton('','delete',this.translate('button_delete_row_title_short'));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 'Delete' text, whereas the the array.js editor displays the item title too. Is this intentional? Nevertheless, I've provided distinct translation keys for both versions of the Delete button text.

self.rows[i].delete_button.className += ' delete';
self.rows[i].delete_button.setAttribute('data-i',i);
self.rows[i].delete_button.addEventListener('click',function(e) {
Expand All @@ -340,7 +340,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({


if(i && !this.hide_move_buttons) {
self.rows[i].moveup_button = this.getButton('','moveup','Move up');
self.rows[i].moveup_button = this.getButton('','moveup',this.translate('button_move_up_title'));
self.rows[i].moveup_button.className += ' moveup';
self.rows[i].moveup_button.setAttribute('data-i',i);
self.rows[i].moveup_button.addEventListener('click',function(e) {
Expand All @@ -361,7 +361,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
}

if(!this.hide_move_buttons) {
self.rows[i].movedown_button = this.getButton('','movedown','Move down');
self.rows[i].movedown_button = this.getButton('','movedown',this.translate('button_move_down_title'));
self.rows[i].movedown_button.className += ' movedown';
self.rows[i].movedown_button.setAttribute('data-i',i);
self.rows[i].movedown_button.addEventListener('click',function(e) {
Expand All @@ -386,7 +386,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
var self = this;

this.collapsed = false;
this.toggle_button = this.getButton('','collapse','Collapse');
this.toggle_button = this.getButton('','collapse',this.translate('button_collapse'));
if(this.title_controls) {
this.title_controls.appendChild(this.toggle_button);
this.toggle_button.addEventListener('click',function(e) {
Expand Down Expand Up @@ -420,7 +420,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
}

// Add "new row" and "delete last" buttons below editor
this.add_row_button = this.getButton(this.getItemTitle(),'add','Add '+this.getItemTitle());
this.add_row_button = this.getButton(this.getItemTitle(),'add',this.translate('button_add_row_title',[this.getItemTitle()]));
this.add_row_button.addEventListener('click',function(e) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -432,7 +432,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
});
self.controls.appendChild(this.add_row_button);

this.delete_last_row_button = this.getButton('Last '+this.getItemTitle(),'delete','Delete Last '+this.getItemTitle());
this.delete_last_row_button = this.getButton(this.translate('button_delete_last',[this.getItemTitle()]),'delete',this.translate('button_delete_last_title',[this.getItemTitle()]));
this.delete_last_row_button.addEventListener('click',function(e) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -444,7 +444,7 @@ JSONEditor.defaults.editors.table = JSONEditor.defaults.editors.array.extend({
});
self.controls.appendChild(this.delete_last_row_button);

this.remove_all_rows_button = this.getButton('All','delete','Delete All');
this.remove_all_rows_button = this.getButton(this.translate('button_delete_all'),'delete',this.translate('button_delete_all_title'));
this.remove_all_rows_button.addEventListener('click',function(e) {
e.preventDefault();
e.stopPropagation();
Expand Down