diff --git a/blocks/colour.js b/blocks/colour.js index 737fe9466..22898f3cb 100644 --- a/blocks/colour.js +++ b/blocks/colour.js @@ -38,7 +38,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.COLOUR_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['COLOUR_HUE']. (2018 April 5) */ Blockly.Constants.Colour.HUE = 20; diff --git a/blocks/lists.js b/blocks/lists.js index 45f596ddc..b8d91c56a 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -37,7 +37,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.LISTS_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['LISTS_HUE']. (2018 April 5) */ Blockly.Constants.Lists.HUE = 260; @@ -132,13 +132,13 @@ Blockly.Blocks['lists_create_with'] = { * @this Blockly.Block */ init: function() { - this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_CREATE_WITH_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); this.itemCount_ = 3; this.updateShape_(); this.setOutput(true, 'Array'); this.setMutator(new Blockly.Mutator(['lists_create_with_item'])); - this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP); + this.setTooltip(Blockly.Msg['LISTS_CREATE_WITH_TOOLTIP']); }, /** * Create XML to represent list inputs. @@ -231,14 +231,14 @@ Blockly.Blocks['lists_create_with'] = { this.removeInput('EMPTY'); } else if (!this.itemCount_ && !this.getInput('EMPTY')) { this.appendDummyInput('EMPTY') - .appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE); + .appendField(Blockly.Msg['LISTS_CREATE_EMPTY_TITLE']); } // Add new inputs. for (var i = 0; i < this.itemCount_; i++) { if (!this.getInput('ADD' + i)) { var input = this.appendValueInput('ADD' + i); if (i == 0) { - input.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH); + input.appendField(Blockly.Msg['LISTS_CREATE_WITH_INPUT_WITH']); } } } @@ -256,11 +256,11 @@ Blockly.Blocks['lists_create_with_container'] = { * @this Blockly.Block */ init: function() { - this.setColour(Blockly.Msg.LISTS_HUE); + this.setColour(Blockly.Msg['LISTS_HUE']); this.appendDummyInput() - .appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD); + .appendField(Blockly.Msg['LISTS_CREATE_WITH_CONTAINER_TITLE_ADD']); this.appendStatementInput('STACK'); - this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP); + this.setTooltip(Blockly.Msg['LISTS_CREATE_WITH_CONTAINER_TOOLTIP']); this.contextMenu = false; } }; @@ -271,12 +271,12 @@ Blockly.Blocks['lists_create_with_item'] = { * @this Blockly.Block */ init: function() { - this.setColour(Blockly.Msg.LISTS_HUE); + this.setColour(Blockly.Msg['LISTS_HUE']); this.appendDummyInput() - .appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE); + .appendField(Blockly.Msg['LISTS_CREATE_WITH_ITEM_TITLE']); this.setPreviousStatement(true); this.setNextStatement(true); - this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP); + this.setTooltip(Blockly.Msg['LISTS_CREATE_WITH_ITEM_TOOLTIP']); this.contextMenu = false; } }; @@ -289,22 +289,22 @@ Blockly.Blocks['lists_indexOf'] = { init: function() { var OPERATORS = [ - [Blockly.Msg.LISTS_INDEX_OF_FIRST, 'FIRST'], - [Blockly.Msg.LISTS_INDEX_OF_LAST, 'LAST'] + [Blockly.Msg['LISTS_INDEX_OF_FIRST'], 'FIRST'], + [Blockly.Msg['LISTS_INDEX_OF_LAST'], 'LAST'] ]; - this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_INDEX_OF_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); this.setOutput(true, 'Number'); this.appendValueInput('VALUE') .setCheck('Array') - .appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST); + .appendField(Blockly.Msg['LISTS_INDEX_OF_INPUT_IN_LIST']); this.appendValueInput('FIND') .appendField(new Blockly.FieldDropdown(OPERATORS), 'END'); this.setInputsInline(true); // Assign 'this' to a variable for use in the tooltip closure below. var thisBlock = this; this.setTooltip(function() { - return Blockly.Msg.LISTS_INDEX_OF_TOOLTIP.replace('%1', + return Blockly.Msg['LISTS_INDEX_OF_TOOLTIP'].replace('%1', thisBlock.workspace.options.oneBasedIndex ? '0' : '-1'); }); } @@ -318,34 +318,34 @@ Blockly.Blocks['lists_getIndex'] = { init: function() { var MODE = [ - [Blockly.Msg.LISTS_GET_INDEX_GET, 'GET'], - [Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE, 'GET_REMOVE'], - [Blockly.Msg.LISTS_GET_INDEX_REMOVE, 'REMOVE'] + [Blockly.Msg['LISTS_GET_INDEX_GET'], 'GET'], + [Blockly.Msg['LISTS_GET_INDEX_GET_REMOVE'], 'GET_REMOVE'], + [Blockly.Msg['LISTS_GET_INDEX_REMOVE'], 'REMOVE'] ]; this.WHERE_OPTIONS = [ - [Blockly.Msg.LISTS_GET_INDEX_FROM_START, 'FROM_START'], - [Blockly.Msg.LISTS_GET_INDEX_FROM_END, 'FROM_END'], - [Blockly.Msg.LISTS_GET_INDEX_FIRST, 'FIRST'], - [Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'], - [Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM'] + [Blockly.Msg['LISTS_GET_INDEX_FROM_START'], 'FROM_START'], + [Blockly.Msg['LISTS_GET_INDEX_FROM_END'], 'FROM_END'], + [Blockly.Msg['LISTS_GET_INDEX_FIRST'], 'FIRST'], + [Blockly.Msg['LISTS_GET_INDEX_LAST'], 'LAST'], + [Blockly.Msg['LISTS_GET_INDEX_RANDOM'], 'RANDOM'] ]; - this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_GET_INDEX_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); var modeMenu = new Blockly.FieldDropdown(MODE, function(value) { var isStatement = (value == 'REMOVE'); this.sourceBlock_.updateStatement_(isStatement); }); this.appendValueInput('VALUE') .setCheck('Array') - .appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST); + .appendField(Blockly.Msg['LISTS_GET_INDEX_INPUT_IN_LIST']); this.appendDummyInput() .appendField(modeMenu, 'MODE') .appendField('', 'SPACE'); this.appendDummyInput('AT'); - if (Blockly.Msg.LISTS_GET_INDEX_TAIL) { + if (Blockly.Msg['LISTS_GET_INDEX_TAIL']) { this.appendDummyInput('TAIL') - .appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL); + .appendField(Blockly.Msg['LISTS_GET_INDEX_TAIL']); } this.setInputsInline(true); this.setOutput(true); @@ -359,48 +359,48 @@ Blockly.Blocks['lists_getIndex'] = { switch (mode + ' ' + where) { case 'GET FROM_START': case 'GET FROM_END': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_FROM']; break; case 'GET FIRST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_FIRST']; break; case 'GET LAST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_LAST']; break; case 'GET RANDOM': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_RANDOM']; break; case 'GET_REMOVE FROM_START': case 'GET_REMOVE FROM_END': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM']; break; case 'GET_REMOVE FIRST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST']; break; case 'GET_REMOVE LAST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST']; break; case 'GET_REMOVE RANDOM': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM']; break; case 'REMOVE FROM_START': case 'REMOVE FROM_END': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM']; break; case 'REMOVE FIRST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST']; break; case 'REMOVE LAST': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST']; break; case 'REMOVE RANDOM': - tooltip = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM; + tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM']; break; } if (where == 'FROM_START' || where == 'FROM_END') { var msg = (where == 'FROM_START') ? - Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP : - Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP; + Blockly.Msg['LISTS_INDEX_FROM_START_TOOLTIP'] : + Blockly.Msg['LISTS_INDEX_FROM_END_TOOLTIP']; tooltip += ' ' + msg.replace('%1', thisBlock.workspace.options.oneBasedIndex ? '#1' : '#0'); } @@ -469,9 +469,9 @@ Blockly.Blocks['lists_getIndex'] = { // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT').setCheck('Number'); - if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { + if (Blockly.Msg['ORDINAL_NUMBER_SUFFIX']) { this.appendDummyInput('ORDINAL') - .appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX); + .appendField(Blockly.Msg['ORDINAL_NUMBER_SUFFIX']); } } else { this.appendDummyInput('AT'); @@ -489,7 +489,7 @@ Blockly.Blocks['lists_getIndex'] = { return undefined; }); this.getInput('AT').appendField(menu, 'WHERE'); - if (Blockly.Msg.LISTS_GET_INDEX_TAIL) { + if (Blockly.Msg['LISTS_GET_INDEX_TAIL']) { this.moveInputBefore('TAIL', null); } } @@ -503,32 +503,32 @@ Blockly.Blocks['lists_setIndex'] = { init: function() { var MODE = [ - [Blockly.Msg.LISTS_SET_INDEX_SET, 'SET'], - [Blockly.Msg.LISTS_SET_INDEX_INSERT, 'INSERT'] + [Blockly.Msg['LISTS_SET_INDEX_SET'], 'SET'], + [Blockly.Msg['LISTS_SET_INDEX_INSERT'], 'INSERT'] ]; this.WHERE_OPTIONS = [ - [Blockly.Msg.LISTS_GET_INDEX_FROM_START, 'FROM_START'], - [Blockly.Msg.LISTS_GET_INDEX_FROM_END, 'FROM_END'], - [Blockly.Msg.LISTS_GET_INDEX_FIRST, 'FIRST'], - [Blockly.Msg.LISTS_GET_INDEX_LAST, 'LAST'], - [Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM'] + [Blockly.Msg['LISTS_GET_INDEX_FROM_START'], 'FROM_START'], + [Blockly.Msg['LISTS_GET_INDEX_FROM_END'], 'FROM_END'], + [Blockly.Msg['LISTS_GET_INDEX_FIRST'], 'FIRST'], + [Blockly.Msg['LISTS_GET_INDEX_LAST'], 'LAST'], + [Blockly.Msg['LISTS_GET_INDEX_RANDOM'], 'RANDOM'] ]; - this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_SET_INDEX_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); this.appendValueInput('LIST') .setCheck('Array') - .appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST); + .appendField(Blockly.Msg['LISTS_SET_INDEX_INPUT_IN_LIST']); this.appendDummyInput() .appendField(new Blockly.FieldDropdown(MODE), 'MODE') .appendField('', 'SPACE'); this.appendDummyInput('AT'); this.appendValueInput('TO') - .appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO); + .appendField(Blockly.Msg['LISTS_SET_INDEX_INPUT_TO']); this.setInputsInline(true); this.setPreviousStatement(true); this.setNextStatement(true); - this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP); + this.setTooltip(Blockly.Msg['LISTS_SET_INDEX_TOOLTIP']); this.updateAt_(true); // Assign 'this' to a variable for use in the tooltip closure below. var thisBlock = this; @@ -539,33 +539,33 @@ Blockly.Blocks['lists_setIndex'] = { switch (mode + ' ' + where) { case 'SET FROM_START': case 'SET FROM_END': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_SET_FROM']; break; case 'SET FIRST': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_SET_FIRST']; break; case 'SET LAST': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_SET_LAST']; break; case 'SET RANDOM': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_SET_RANDOM']; break; case 'INSERT FROM_START': case 'INSERT FROM_END': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_INSERT_FROM']; break; case 'INSERT FIRST': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST']; break; case 'INSERT LAST': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_INSERT_LAST']; break; case 'INSERT RANDOM': - tooltip = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM; + tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM']; break; } if (where == 'FROM_START' || where == 'FROM_END') { - tooltip += ' ' + Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP + tooltip += ' ' + Blockly.Msg['LISTS_INDEX_FROM_START_TOOLTIP'] .replace('%1', thisBlock.workspace.options.oneBasedIndex ? '#1' : '#0'); } @@ -607,9 +607,9 @@ Blockly.Blocks['lists_setIndex'] = { // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT').setCheck('Number'); - if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { + if (Blockly.Msg['ORDINAL_NUMBER_SUFFIX']) { this.appendDummyInput('ORDINAL') - .appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX); + .appendField(Blockly.Msg['ORDINAL_NUMBER_SUFFIX']); } } else { this.appendDummyInput('AT'); @@ -643,32 +643,32 @@ Blockly.Blocks['lists_getSublist'] = { init: function() { this['WHERE_OPTIONS_1'] = [ - [Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START, 'FROM_START'], - [Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END, 'FROM_END'], - [Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST, 'FIRST'] + [Blockly.Msg['LISTS_GET_SUBLIST_START_FROM_START'], 'FROM_START'], + [Blockly.Msg['LISTS_GET_SUBLIST_START_FROM_END'], 'FROM_END'], + [Blockly.Msg['LISTS_GET_SUBLIST_START_FIRST'], 'FIRST'] ]; this['WHERE_OPTIONS_2'] = [ - [Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START, 'FROM_START'], - [Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END, 'FROM_END'], - [Blockly.Msg.LISTS_GET_SUBLIST_END_LAST, 'LAST'] + [Blockly.Msg['LISTS_GET_SUBLIST_END_FROM_START'], 'FROM_START'], + [Blockly.Msg['LISTS_GET_SUBLIST_END_FROM_END'], 'FROM_END'], + [Blockly.Msg['LISTS_GET_SUBLIST_END_LAST'], 'LAST'] ]; - this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_GET_SUBLIST_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); this.appendValueInput('LIST') .setCheck('Array') - .appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST); + .appendField(Blockly.Msg['LISTS_GET_SUBLIST_INPUT_IN_LIST']); this.appendDummyInput('AT1'); this.appendDummyInput('AT2'); - if (Blockly.Msg.LISTS_GET_SUBLIST_TAIL) { + if (Blockly.Msg['LISTS_GET_SUBLIST_TAIL']) { this.appendDummyInput('TAIL') - .appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL); + .appendField(Blockly.Msg['LISTS_GET_SUBLIST_TAIL']); } this.setInputsInline(true); this.setOutput(true, 'Array'); this.updateAt_(1, true); this.updateAt_(2, true); - this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP); + this.setTooltip(Blockly.Msg['LISTS_GET_SUBLIST_TOOLTIP']); }, /** * Create XML to represent whether there are 'AT' inputs. @@ -710,9 +710,9 @@ Blockly.Blocks['lists_getSublist'] = { // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT' + n).setCheck('Number'); - if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { + if (Blockly.Msg['ORDINAL_NUMBER_SUFFIX']) { this.appendDummyInput('ORDINAL' + n) - .appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX); + .appendField(Blockly.Msg['ORDINAL_NUMBER_SUFFIX']); } } else { this.appendDummyInput('AT' + n); @@ -740,7 +740,7 @@ Blockly.Blocks['lists_getSublist'] = { this.moveInputBefore('ORDINAL1', 'AT2'); } } - if (Blockly.Msg.LISTS_GET_SUBLIST_TAIL) { + if (Blockly.Msg['LISTS_GET_SUBLIST_TAIL']) { this.moveInputBefore('TAIL', null); } } @@ -753,23 +753,23 @@ Blockly.Blocks['lists_sort'] = { */ init: function() { this.jsonInit({ - "message0": Blockly.Msg.LISTS_SORT_TITLE, + "message0": Blockly.Msg['LISTS_SORT_TITLE'], "args0": [ { "type": "field_dropdown", "name": "TYPE", "options": [ - [Blockly.Msg.LISTS_SORT_TYPE_NUMERIC, "NUMERIC"], - [Blockly.Msg.LISTS_SORT_TYPE_TEXT, "TEXT"], - [Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE, "IGNORE_CASE"] + [Blockly.Msg['LISTS_SORT_TYPE_NUMERIC'], "NUMERIC"], + [Blockly.Msg['LISTS_SORT_TYPE_TEXT'], "TEXT"], + [Blockly.Msg['LISTS_SORT_TYPE_IGNORECASE'], "IGNORE_CASE"] ] }, { "type": "field_dropdown", "name": "DIRECTION", "options": [ - [Blockly.Msg.LISTS_SORT_ORDER_ASCENDING, "1"], - [Blockly.Msg.LISTS_SORT_ORDER_DESCENDING, "-1"] + [Blockly.Msg['LISTS_SORT_ORDER_ASCENDING'], "1"], + [Blockly.Msg['LISTS_SORT_ORDER_DESCENDING'], "-1"] ] }, { @@ -779,9 +779,9 @@ Blockly.Blocks['lists_sort'] = { } ], "output": "Array", - "colour": Blockly.Msg.LISTS_HUE, - "tooltip": Blockly.Msg.LISTS_SORT_TOOLTIP, - "helpUrl": Blockly.Msg.LISTS_SORT_HELPURL + "colour": Blockly.Msg['LISTS_HUE'], + "tooltip": Blockly.Msg['LISTS_SORT_TOOLTIP'], + "helpUrl": Blockly.Msg['LISTS_SORT_HELPURL'] }); } }; @@ -796,28 +796,28 @@ Blockly.Blocks['lists_split'] = { var thisBlock = this; var dropdown = new Blockly.FieldDropdown( [ - [Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, 'SPLIT'], - [Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, 'JOIN'] + [Blockly.Msg['LISTS_SPLIT_LIST_FROM_TEXT'], 'SPLIT'], + [Blockly.Msg['LISTS_SPLIT_TEXT_FROM_LIST'], 'JOIN'] ], function(newMode) { thisBlock.updateType_(newMode); }); - this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL); - this.setColour(Blockly.Msg.LISTS_HUE); + this.setHelpUrl(Blockly.Msg['LISTS_SPLIT_HELPURL']); + this.setColour(Blockly.Msg['LISTS_HUE']); this.appendValueInput('INPUT') .setCheck('String') .appendField(dropdown, 'MODE'); this.appendValueInput('DELIM') .setCheck('String') - .appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER); + .appendField(Blockly.Msg['LISTS_SPLIT_WITH_DELIMITER']); this.setInputsInline(true); this.setOutput(true, 'Array'); this.setTooltip(function() { var mode = thisBlock.getFieldValue('MODE'); if (mode == 'SPLIT') { - return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT; + return Blockly.Msg['LISTS_SPLIT_TOOLTIP_SPLIT']; } else if (mode == 'JOIN') { - return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN; + return Blockly.Msg['LISTS_SPLIT_TOOLTIP_JOIN']; } throw 'Unknown mode: ' + mode; }); diff --git a/blocks/logic.js b/blocks/logic.js index 15b08170f..efde8e2be 100644 --- a/blocks/logic.js +++ b/blocks/logic.js @@ -37,7 +37,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.LOGIC_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['LOGIC_HUE']. (2018 April 5) */ Blockly.Constants.Logic.HUE = 210; @@ -445,13 +445,13 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = { for (var i = 1; i <= this.elseifCount_; i++) { this.appendValueInput('IF' + i) .setCheck('Boolean') - .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF); + .appendField(Blockly.Msg['CONTROLS_IF_MSG_ELSEIF']); this.appendStatementInput('DO' + i) - .appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); + .appendField(Blockly.Msg['CONTROLS_IF_MSG_THEN']); } if (this.elseCount_) { this.appendStatementInput('ELSE') - .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE); + .appendField(Blockly.Msg['CONTROLS_IF_MSG_ELSE']); } } }; @@ -469,13 +469,13 @@ Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION = function() { this.setTooltip(function() { if (!this.elseifCount_ && !this.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_1; + return Blockly.Msg['CONTROLS_IF_TOOLTIP_1']; } else if (!this.elseifCount_ && this.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_2; + return Blockly.Msg['CONTROLS_IF_TOOLTIP_2']; } else if (this.elseifCount_ && !this.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_3; + return Blockly.Msg['CONTROLS_IF_TOOLTIP_3']; } else if (this.elseifCount_ && this.elseCount_) { - return Blockly.Msg.CONTROLS_IF_TOOLTIP_4; + return Blockly.Msg['CONTROLS_IF_TOOLTIP_4']; } return ''; }.bind(this)); diff --git a/blocks/loops.js b/blocks/loops.js index a6db80d11..552886ce4 100644 --- a/blocks/loops.js +++ b/blocks/loops.js @@ -38,7 +38,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.LOOPS_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['LOOPS_HUE']. (2018 April 5) */ Blockly.Constants.Loops.HUE = 120; @@ -266,7 +266,7 @@ Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN = { if (!this.isCollapsed() && varName != null) { var option = {enabled: true}; option.text = - Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', varName); + Blockly.Msg['VARIABLES_SET_CREATE_GET'].replace('%1', varName); var xmlField = Blockly.Variables.generateVariableFieldDom(variable); var xmlBlock = goog.dom.createDom('block', null, xmlField); xmlBlock.setAttribute('type', 'variables_get'); @@ -330,7 +330,7 @@ Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = { this.setDisabled(false); } } else { - this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); + this.setWarningText(Blockly.Msg['CONTROLS_FLOW_STATEMENTS_WARNING']); if (!this.isInFlyout && !this.getInheritedDisabled()) { this.setDisabled(true); } diff --git a/blocks/math.js b/blocks/math.js index 378149e5f..9f95654af 100644 --- a/blocks/math.js +++ b/blocks/math.js @@ -38,7 +38,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.MATH_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['MATH_HUE']. (2018 April 5) */ Blockly.Constants.Math.HUE = 230; diff --git a/blocks/procedures.js b/blocks/procedures.js index 4811c1a26..7241dcf50 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -40,19 +40,19 @@ Blockly.Blocks['procedures_defnoreturn'] = { Blockly.Procedures.rename); nameField.setSpellcheck(false); this.appendDummyInput() - .appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE) + .appendField(Blockly.Msg['PROCEDURES_DEFNORETURN_TITLE']) .appendField(nameField, 'NAME') .appendField('', 'PARAMS'); this.setMutator(new Blockly.Mutator(['procedures_mutatorarg'])); if ((this.workspace.options.comments || (this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments)) && - Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT) { - this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT); + Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']) { + this.setCommentText(Blockly.Msg['PROCEDURES_DEFNORETURN_COMMENT']); } - this.setColour(Blockly.Msg.PROCEDURES_HUE); - this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP); - this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); + this.setTooltip(Blockly.Msg['PROCEDURES_DEFNORETURN_TOOLTIP']); + this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFNORETURN_HELPURL']); this.arguments_ = []; this.argumentVarModels_ = []; this.setStatements_(true); @@ -69,7 +69,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { } if (hasStatements) { this.appendStatementInput('STACK') - .appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO); + .appendField(Blockly.Msg['PROCEDURES_DEFNORETURN_DO']); if (this.getInput('RETURN')) { this.moveInputBefore('STACK', 'RETURN'); } @@ -96,14 +96,14 @@ Blockly.Blocks['procedures_defnoreturn'] = { hash['arg_' + this.arguments_[i].toLowerCase()] = true; } if (badArg) { - this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING); + this.setWarningText(Blockly.Msg['PROCEDURES_DEF_DUPLICATE_WARNING']); } else { this.setWarningText(null); } // Merge the arguments into a human-readable list. var paramString = ''; if (this.arguments_.length) { - paramString = Blockly.Msg.PROCEDURES_BEFORE_PARAMS + + paramString = Blockly.Msg['PROCEDURES_BEFORE_PARAMS'] + ' ' + this.arguments_.join(', '); } // The params field is deterministic based on the mutation, @@ -356,7 +356,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { // Add option to create caller. var option = {enabled: true}; var name = this.getFieldValue('NAME'); - option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name); + option.text = Blockly.Msg['PROCEDURES_CREATE_DO'].replace('%1', name); var xmlMutation = goog.dom.createDom('mutation'); xmlMutation.setAttribute('name', name); for (var i = 0; i < this.arguments_.length; i++) { @@ -375,7 +375,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { var option = {enabled: true}; var argVar = this.argumentVarModels_[i]; var name = argVar.name; - option.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', name); + option.text = Blockly.Msg['VARIABLES_SET_CREATE_GET'].replace('%1', name); var xmlField = Blockly.Variables.generateVariableFieldDom(argVar); var xmlBlock = goog.dom.createDom('block', null, xmlField); @@ -398,22 +398,22 @@ Blockly.Blocks['procedures_defreturn'] = { Blockly.Procedures.rename); nameField.setSpellcheck(false); this.appendDummyInput() - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE) + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_TITLE']) .appendField(nameField, 'NAME') .appendField('', 'PARAMS'); this.appendValueInput('RETURN') .setAlign(Blockly.ALIGN_RIGHT) - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']); this.setMutator(new Blockly.Mutator(['procedures_mutatorarg'])); if ((this.workspace.options.comments || (this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments)) && - Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT) { - this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT); + Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']) { + this.setCommentText(Blockly.Msg['PROCEDURES_DEFRETURN_COMMENT']); } - this.setColour(Blockly.Msg.PROCEDURES_HUE); - this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP); - this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); + this.setTooltip(Blockly.Msg['PROCEDURES_DEFRETURN_TOOLTIP']); + this.setHelpUrl(Blockly.Msg['PROCEDURES_DEFRETURN_HELPURL']); this.arguments_ = []; this.argumentVarModels_ = []; this.setStatements_(true); @@ -452,13 +452,13 @@ Blockly.Blocks['procedures_mutatorcontainer'] = { */ init: function() { this.appendDummyInput() - .appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE); + .appendField(Blockly.Msg['PROCEDURES_MUTATORCONTAINER_TITLE']); this.appendStatementInput('STACK'); this.appendDummyInput('STATEMENT_INPUT') - .appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS) + .appendField(Blockly.Msg['PROCEDURES_ALLOW_STATEMENTS']) .appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS'); - this.setColour(Blockly.Msg.PROCEDURES_HUE); - this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); + this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORCONTAINER_TOOLTIP']); this.contextMenu = false; } }; @@ -480,12 +480,12 @@ Blockly.Blocks['procedures_mutatorarg'] = { field.showEditor_ = newShowEditorFn; this.appendDummyInput() - .appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE) + .appendField(Blockly.Msg['PROCEDURES_MUTATORARG_TITLE']) .appendField(field, 'NAME'); this.setPreviousStatement(true); this.setNextStatement(true); - this.setColour(Blockly.Msg.PROCEDURES_HUE); - this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); + this.setTooltip(Blockly.Msg['PROCEDURES_MUTATORARG_TOOLTIP']); this.contextMenu = false; // Create the default variable when we drag the block in from the flyout. @@ -557,9 +557,9 @@ Blockly.Blocks['procedures_callnoreturn'] = { .appendField(this.id, 'NAME'); this.setPreviousStatement(true); this.setNextStatement(true); - this.setColour(Blockly.Msg.PROCEDURES_HUE); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); // Tooltip is set in renameProcedure. - this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL); + this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLNORETURN_HELPURL']); this.arguments_ = []; this.argumentVarModels_ = []; this.quarkConnections_ = {}; @@ -585,8 +585,8 @@ Blockly.Blocks['procedures_callnoreturn'] = { if (Blockly.Names.equals(oldName, this.getProcedureCall())) { this.setFieldValue(newName, 'NAME'); var baseMsg = this.outputConnection ? - Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP : - Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP; + Blockly.Msg['PROCEDURES_CALLRETURN_TOOLTIP'] : + Blockly.Msg['PROCEDURES_CALLNORETURN_TOOLTIP']; this.setTooltip(baseMsg.replace('%1', newName)); } }, @@ -726,7 +726,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { if (topRow) { if (this.arguments_.length) { if (!this.getField('WITH')) { - topRow.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH'); + topRow.appendField(Blockly.Msg['PROCEDURES_CALL_BEFORE_PARAMS'], 'WITH'); topRow.init(); } } else { @@ -851,7 +851,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { */ customContextMenu: function(options) { var option = {enabled: true}; - option.text = Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF; + option.text = Blockly.Msg['PROCEDURES_HIGHLIGHT_DEF']; var name = this.getProcedureCall(); var workspace = this.workspace; option.callback = function() { @@ -875,9 +875,9 @@ Blockly.Blocks['procedures_callreturn'] = { this.appendDummyInput('TOPROW') .appendField('', 'NAME'); this.setOutput(true); - this.setColour(Blockly.Msg.PROCEDURES_HUE); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); // Tooltip is set in domToMutation. - this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL); + this.setHelpUrl(Blockly.Msg['PROCEDURES_CALLRETURN_HELPURL']); this.arguments_ = []; this.quarkConnections_ = {}; this.quarkIds_ = null; @@ -904,15 +904,15 @@ Blockly.Blocks['procedures_ifreturn'] = { init: function() { this.appendValueInput('CONDITION') .setCheck('Boolean') - .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); + .appendField(Blockly.Msg['CONTROLS_IF_MSG_IF']); this.appendValueInput('VALUE') - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']); this.setInputsInline(true); this.setPreviousStatement(true); this.setNextStatement(true); - this.setColour(Blockly.Msg.PROCEDURES_HUE); - this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP); - this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL); + this.setColour(Blockly.Msg['PROCEDURES_HUE']); + this.setTooltip(Blockly.Msg['PROCEDURES_IFRETURN_TOOLTIP']); + this.setHelpUrl(Blockly.Msg['PROCEDURES_IFRETURN_HELPURL']); this.hasReturnValue_ = true; }, /** @@ -936,7 +936,7 @@ Blockly.Blocks['procedures_ifreturn'] = { if (!this.hasReturnValue_) { this.removeInput('VALUE'); this.appendDummyInput('VALUE') - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']); } }, /** @@ -964,13 +964,13 @@ Blockly.Blocks['procedures_ifreturn'] = { if (block.type == 'procedures_defnoreturn' && this.hasReturnValue_) { this.removeInput('VALUE'); this.appendDummyInput('VALUE') - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']); this.hasReturnValue_ = false; } else if (block.type == 'procedures_defreturn' && !this.hasReturnValue_) { this.removeInput('VALUE'); this.appendValueInput('VALUE') - .appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN); + .appendField(Blockly.Msg['PROCEDURES_DEFRETURN_RETURN']); this.hasReturnValue_ = true; } this.setWarningText(null); @@ -978,7 +978,7 @@ Blockly.Blocks['procedures_ifreturn'] = { this.setDisabled(false); } } else { - this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING); + this.setWarningText(Blockly.Msg['PROCEDURES_IFRETURN_WARNING']); if (!this.isInFlyout && !this.getInheritedDisabled()) { this.setDisabled(true); } diff --git a/blocks/text.js b/blocks/text.js index 5b5ae7d2f..d1e825b75 100644 --- a/blocks/text.js +++ b/blocks/text.js @@ -33,7 +33,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.TEXTS_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['TEXTS_HUE']. (2018 April 5) */ Blockly.Constants.Text.HUE = 160; @@ -211,31 +211,31 @@ Blockly.Blocks['text_getSubstring'] = { */ init: function() { this['WHERE_OPTIONS_1'] = [ - [Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START, 'FROM_START'], - [Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END, 'FROM_END'], - [Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST, 'FIRST'] + [Blockly.Msg['TEXT_GET_SUBSTRING_START_FROM_START'], 'FROM_START'], + [Blockly.Msg['TEXT_GET_SUBSTRING_START_FROM_END'], 'FROM_END'], + [Blockly.Msg['TEXT_GET_SUBSTRING_START_FIRST'], 'FIRST'] ]; this['WHERE_OPTIONS_2'] = [ - [Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START, 'FROM_START'], - [Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END, 'FROM_END'], - [Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST, 'LAST'] + [Blockly.Msg['TEXT_GET_SUBSTRING_END_FROM_START'], 'FROM_START'], + [Blockly.Msg['TEXT_GET_SUBSTRING_END_FROM_END'], 'FROM_END'], + [Blockly.Msg['TEXT_GET_SUBSTRING_END_LAST'], 'LAST'] ]; - this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL); - this.setColour(Blockly.Msg.TEXTS_HUE); + this.setHelpUrl(Blockly.Msg['TEXT_GET_SUBSTRING_HELPURL']); + this.setColour(Blockly.Msg['TEXTS_HUE']); this.appendValueInput('STRING') .setCheck('String') - .appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT); + .appendField(Blockly.Msg['TEXT_GET_SUBSTRING_INPUT_IN_TEXT']); this.appendDummyInput('AT1'); this.appendDummyInput('AT2'); - if (Blockly.Msg.TEXT_GET_SUBSTRING_TAIL) { + if (Blockly.Msg['TEXT_GET_SUBSTRING_TAIL']) { this.appendDummyInput('TAIL') - .appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL); + .appendField(Blockly.Msg['TEXT_GET_SUBSTRING_TAIL']); } this.setInputsInline(true); this.setOutput(true, 'String'); this.updateAt_(1, true); this.updateAt_(2, true); - this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP); + this.setTooltip(Blockly.Msg['TEXT_GET_SUBSTRING_TOOLTIP']); }, /** * Create XML to represent whether there are 'AT' inputs. @@ -277,18 +277,18 @@ Blockly.Blocks['text_getSubstring'] = { // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT' + n).setCheck('Number'); - if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { + if (Blockly.Msg['ORDINAL_NUMBER_SUFFIX']) { this.appendDummyInput('ORDINAL' + n) - .appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX); + .appendField(Blockly.Msg['ORDINAL_NUMBER_SUFFIX']); } } else { this.appendDummyInput('AT' + n); } // Move tail, if present, to end of block. - if (n == 2 && Blockly.Msg.TEXT_GET_SUBSTRING_TAIL) { + if (n == 2 && Blockly.Msg['TEXT_GET_SUBSTRING_TAIL']) { this.removeInput('TAIL', true); this.appendDummyInput('TAIL') - .appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL); + .appendField(Blockly.Msg['TEXT_GET_SUBSTRING_TAIL']); } var menu = new Blockly.FieldDropdown(this['WHERE_OPTIONS_' + n], function(value) { @@ -324,17 +324,17 @@ Blockly.Blocks['text_changeCase'] = { */ init: function() { var OPERATORS = [ - [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE, 'UPPERCASE'], - [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE, 'LOWERCASE'], - [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, 'TITLECASE'] + [Blockly.Msg['TEXT_CHANGECASE_OPERATOR_UPPERCASE'], 'UPPERCASE'], + [Blockly.Msg['TEXT_CHANGECASE_OPERATOR_LOWERCASE'], 'LOWERCASE'], + [Blockly.Msg['TEXT_CHANGECASE_OPERATOR_TITLECASE'], 'TITLECASE'] ]; - this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL); - this.setColour(Blockly.Msg.TEXTS_HUE); + this.setHelpUrl(Blockly.Msg['TEXT_CHANGECASE_HELPURL']); + this.setColour(Blockly.Msg['TEXTS_HUE']); this.appendValueInput('TEXT') .setCheck('String') .appendField(new Blockly.FieldDropdown(OPERATORS), 'CASE'); this.setOutput(true, 'String'); - this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP); + this.setTooltip(Blockly.Msg['TEXT_CHANGECASE_TOOLTIP']); } }; @@ -345,17 +345,17 @@ Blockly.Blocks['text_trim'] = { */ init: function() { var OPERATORS = [ - [Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH, 'BOTH'], - [Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT, 'LEFT'], - [Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT, 'RIGHT'] + [Blockly.Msg['TEXT_TRIM_OPERATOR_BOTH'], 'BOTH'], + [Blockly.Msg['TEXT_TRIM_OPERATOR_LEFT'], 'LEFT'], + [Blockly.Msg['TEXT_TRIM_OPERATOR_RIGHT'], 'RIGHT'] ]; - this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL); - this.setColour(Blockly.Msg.TEXTS_HUE); + this.setHelpUrl(Blockly.Msg['TEXT_TRIM_HELPURL']); + this.setColour(Blockly.Msg['TEXTS_HUE']); this.appendValueInput('TEXT') .setCheck('String') .appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE'); this.setOutput(true, 'String'); - this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP); + this.setTooltip(Blockly.Msg['TEXT_TRIM_TOOLTIP']); } }; @@ -366,7 +366,7 @@ Blockly.Blocks['text_print'] = { */ init: function() { this.jsonInit({ - "message0": Blockly.Msg.TEXT_PRINT_TITLE, + "message0": Blockly.Msg['TEXT_PRINT_TITLE'], "args0": [ { "type": "input_value", @@ -375,9 +375,9 @@ Blockly.Blocks['text_print'] = { ], "previousStatement": null, "nextStatement": null, - "colour": Blockly.Msg.TEXTS_HUE, - "tooltip": Blockly.Msg.TEXT_PRINT_TOOLTIP, - "helpUrl": Blockly.Msg.TEXT_PRINT_HELPURL + "colour": Blockly.Msg['TEXTS_HUE'], + "tooltip": Blockly.Msg['TEXT_PRINT_TOOLTIP'], + "helpUrl": Blockly.Msg['TEXT_PRINT_HELPURL'] }); } }; @@ -389,11 +389,11 @@ Blockly.Blocks['text_prompt_ext'] = { */ init: function() { var TYPES = [ - [Blockly.Msg.TEXT_PROMPT_TYPE_TEXT, 'TEXT'], - [Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, 'NUMBER'] + [Blockly.Msg['TEXT_PROMPT_TYPE_TEXT'], 'TEXT'], + [Blockly.Msg['TEXT_PROMPT_TYPE_NUMBER'], 'NUMBER'] ]; - this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL); - this.setColour(Blockly.Msg.TEXTS_HUE); + this.setHelpUrl(Blockly.Msg['TEXT_PROMPT_HELPURL']); + this.setColour(Blockly.Msg['TEXTS_HUE']); // Assign 'this' to a variable for use in the closures below. var thisBlock = this; var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) { @@ -404,8 +404,8 @@ Blockly.Blocks['text_prompt_ext'] = { this.setOutput(true, 'String'); this.setTooltip(function() { return (thisBlock.getFieldValue('TYPE') == 'TEXT') ? - Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT : - Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER; + Blockly.Msg['TEXT_PROMPT_TOOLTIP_TEXT'] : + Blockly.Msg['TEXT_PROMPT_TOOLTIP_NUMBER']; }); }, /** @@ -446,14 +446,14 @@ Blockly.Blocks['text_prompt'] = { init: function() { this.mixin(Blockly.Constants.Text.QUOTE_IMAGE_MIXIN); var TYPES = [ - [Blockly.Msg.TEXT_PROMPT_TYPE_TEXT, 'TEXT'], - [Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, 'NUMBER'] + [Blockly.Msg['TEXT_PROMPT_TYPE_TEXT'], 'TEXT'], + [Blockly.Msg['TEXT_PROMPT_TYPE_NUMBER'], 'NUMBER'] ]; // Assign 'this' to a variable for use in the closures below. var thisBlock = this; - this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL); - this.setColour(Blockly.Msg.TEXTS_HUE); + this.setHelpUrl(Blockly.Msg['TEXT_PROMPT_HELPURL']); + this.setColour(Blockly.Msg['TEXTS_HUE']); var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) { thisBlock.updateType_(newOp); }); @@ -465,8 +465,8 @@ Blockly.Blocks['text_prompt'] = { this.setOutput(true, 'String'); this.setTooltip(function() { return (thisBlock.getFieldValue('TYPE') == 'TEXT') ? - Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT : - Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER; + Blockly.Msg['TEXT_PROMPT_TOOLTIP_TEXT'] : + Blockly.Msg['TEXT_PROMPT_TOOLTIP_NUMBER']; }); }, updateType_: Blockly.Blocks['text_prompt_ext'].updateType_, @@ -481,7 +481,7 @@ Blockly.Blocks['text_count'] = { */ init: function() { this.jsonInit({ - "message0": Blockly.Msg.TEXT_COUNT_MESSAGE0, + "message0": Blockly.Msg['TEXT_COUNT_MESSAGE0'], "args0": [ { "type": "input_value", @@ -496,9 +496,9 @@ Blockly.Blocks['text_count'] = { ], "output": "Number", "inputsInline": true, - "colour": Blockly.Msg.TEXTS_HUE, - "tooltip": Blockly.Msg.TEXT_COUNT_TOOLTIP, - "helpUrl": Blockly.Msg.TEXT_COUNT_HELPURL + "colour": Blockly.Msg['TEXTS_HUE'], + "tooltip": Blockly.Msg['TEXT_COUNT_TOOLTIP'], + "helpUrl": Blockly.Msg['TEXT_COUNT_HELPURL'] }); } }; @@ -510,7 +510,7 @@ Blockly.Blocks['text_replace'] = { */ init: function() { this.jsonInit({ - "message0": Blockly.Msg.TEXT_REPLACE_MESSAGE0, + "message0": Blockly.Msg['TEXT_REPLACE_MESSAGE0'], "args0": [ { "type": "input_value", @@ -530,9 +530,9 @@ Blockly.Blocks['text_replace'] = { ], "output": "String", "inputsInline": true, - "colour": Blockly.Msg.TEXTS_HUE, - "tooltip": Blockly.Msg.TEXT_REPLACE_TOOLTIP, - "helpUrl": Blockly.Msg.TEXT_REPLACE_HELPURL + "colour": Blockly.Msg['TEXTS_HUE'], + "tooltip": Blockly.Msg['TEXT_REPLACE_TOOLTIP'], + "helpUrl": Blockly.Msg['TEXT_REPLACE_HELPURL'] }); } }; @@ -544,7 +544,7 @@ Blockly.Blocks['text_reverse'] = { */ init: function() { this.jsonInit({ - "message0": Blockly.Msg.TEXT_REVERSE_MESSAGE0, + "message0": Blockly.Msg['TEXT_REVERSE_MESSAGE0'], "args0": [ { "type": "input_value", @@ -554,9 +554,9 @@ Blockly.Blocks['text_reverse'] = { ], "output": "String", "inputsInline": true, - "colour": Blockly.Msg.TEXTS_HUE, - "tooltip": Blockly.Msg.TEXT_REVERSE_TOOLTIP, - "helpUrl": Blockly.Msg.TEXT_REVERSE_HELPURL + "colour": Blockly.Msg['TEXTS_HUE'], + "tooltip": Blockly.Msg['TEXT_REVERSE_TOOLTIP'], + "helpUrl": Blockly.Msg['TEXT_REVERSE_HELPURL'] }); } }; @@ -753,7 +753,7 @@ Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN = { if (!this.getInput('ADD' + i)) { var input = this.appendValueInput('ADD' + i); if (i == 0) { - input.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH); + input.appendField(Blockly.Msg['TEXT_JOIN_TITLE_CREATEWITH']); } } } @@ -792,7 +792,7 @@ Blockly.Constants.Text.TEXT_INDEXOF_TOOLTIP_EXTENSION = function() { // Assign 'this' to a variable for use in the tooltip closure below. var thisBlock = this; this.setTooltip(function() { - return Blockly.Msg.TEXT_INDEXOF_TOOLTIP.replace('%1', + return Blockly.Msg['TEXT_INDEXOF_TOOLTIP'].replace('%1', thisBlock.workspace.options.oneBasedIndex ? '0' : '-1'); }); }; @@ -838,15 +838,15 @@ Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN = { // Create either a value 'AT' input or a dummy input. if (isAt) { this.appendValueInput('AT').setCheck('Number'); - if (Blockly.Msg.ORDINAL_NUMBER_SUFFIX) { + if (Blockly.Msg['ORDINAL_NUMBER_SUFFIX']) { this.appendDummyInput('ORDINAL') - .appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX); + .appendField(Blockly.Msg['ORDINAL_NUMBER_SUFFIX']); } } - if (Blockly.Msg.TEXT_CHARAT_TAIL) { + if (Blockly.Msg['TEXT_CHARAT_TAIL']) { this.removeInput('TAIL', true); this.appendDummyInput('TAIL') - .appendField(Blockly.Msg.TEXT_CHARAT_TAIL); + .appendField(Blockly.Msg['TEXT_CHARAT_TAIL']); } this.isAt_ = isAt; @@ -875,11 +875,11 @@ Blockly.Constants.Text.TEXT_CHARAT_EXTENSION = function() { var thisBlock = this; this.setTooltip(function() { var where = thisBlock.getFieldValue('WHERE'); - var tooltip = Blockly.Msg.TEXT_CHARAT_TOOLTIP; + var tooltip = Blockly.Msg['TEXT_CHARAT_TOOLTIP']; if (where == 'FROM_START' || where == 'FROM_END') { var msg = (where == 'FROM_START') ? - Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP : - Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP; + Blockly.Msg['LISTS_INDEX_FROM_START_TOOLTIP'] : + Blockly.Msg['LISTS_INDEX_FROM_END_TOOLTIP']; if (msg) { tooltip += ' ' + msg.replace('%1', thisBlock.workspace.options.oneBasedIndex ? '#1' : '#0'); diff --git a/blocks/variables.js b/blocks/variables.js index cf8fa2d96..4d7b9f38d 100644 --- a/blocks/variables.js +++ b/blocks/variables.js @@ -38,7 +38,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.VARIABLES_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['VARIABLES_HUE']. (2018 April 5) */ Blockly.Constants.Variables.HUE = 330; @@ -106,10 +106,10 @@ Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN = { // Getter blocks have the option to create a setter block, and vice versa. if (this.type == 'variables_get') { var opposite_type = 'variables_set'; - var contextMenuMsg = Blockly.Msg.VARIABLES_GET_CREATE_SET; + var contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET']; } else { var opposite_type = 'variables_get'; - var contextMenuMsg = Blockly.Msg.VARIABLES_SET_CREATE_GET; + var contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET']; } var option = {enabled: this.workspace.remainingCapacity() > 0}; diff --git a/blocks/variables_dynamic.js b/blocks/variables_dynamic.js index a9f568a7c..87462b1b4 100644 --- a/blocks/variables_dynamic.js +++ b/blocks/variables_dynamic.js @@ -37,7 +37,7 @@ goog.require('Blockly'); /** * Unused constant for the common HSV hue for all blocks in this category. - * @deprecated Use Blockly.Msg.VARIABLES_DYNAMIC_HUE. (2018 April 5) + * @deprecated Use Blockly.Msg['VARIABLES_DYNAMIC_HUE']. (2018 April 5) */ Blockly.Constants.VariablesDynamic.HUE = 310; @@ -104,10 +104,10 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI var contextMenuMsg; if (this.type == 'variables_get_dynamic') { opposite_type = 'variables_set_dynamic'; - contextMenuMsg = Blockly.Msg.VARIABLES_GET_CREATE_SET; + contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET']; } else { opposite_type = 'variables_get_dynamic'; - contextMenuMsg = Blockly.Msg.VARIABLES_SET_CREATE_GET; + contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET']; } var option = {enabled: this.workspace.remainingCapacity() > 0}; diff --git a/core/block_svg.js b/core/block_svg.js index 3215826ed..e1fda02f6 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -617,7 +617,7 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { var inlineOption = {enabled: true}; var isInline = this.getInputsInline(); inlineOption.text = isInline ? - Blockly.Msg.EXTERNAL_INPUTS : Blockly.Msg.INLINE_INPUTS; + Blockly.Msg['EXTERNAL_INPUTS'] : Blockly.Msg['INLINE_INPUTS']; inlineOption.callback = function() { block.setInputsInline(!isInline); }; @@ -631,14 +631,14 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { // Option to collapse/expand block. if (this.collapsed_) { var expandOption = {enabled: true}; - expandOption.text = Blockly.Msg.EXPAND_BLOCK; + expandOption.text = Blockly.Msg['EXPAND_BLOCK']; expandOption.callback = function() { block.setCollapsed(false); }; menuOptions.push(expandOption); } else { var collapseOption = {enabled: true}; - collapseOption.text = Blockly.Msg.COLLAPSE_BLOCK; + collapseOption.text = Blockly.Msg['COLLAPSE_BLOCK']; collapseOption.callback = function() { block.setCollapsed(true); }; @@ -650,7 +650,7 @@ Blockly.BlockSvg.prototype.showContextMenu_ = function(e) { // Option to disable/enable block. var disableOption = { text: this.disabled ? - Blockly.Msg.ENABLE_BLOCK : Blockly.Msg.DISABLE_BLOCK, + Blockly.Msg['ENABLE_BLOCK'] : Blockly.Msg['DISABLE_BLOCK'], enabled: !this.getInheritedDisabled(), callback: function() { block.setDisabled(!block.disabled); diff --git a/core/blockly.js b/core/blockly.js index 1c1c80983..5abe39f62 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -633,8 +633,8 @@ Blockly.checkBlockColourConstant_ = function( if (value && value !== expectedValue) { var warningPattern = (expectedValue === undefined) ? - '%1 has been removed. Use Blockly.Msg.%2.' : - '%1 is deprecated and unused. Override Blockly.Msg.%2.'; + '%1 has been removed. Use Blockly.Msg["%2"].' : + '%1 is deprecated and unused. Override Blockly.Msg["%2"].'; var warning = warningPattern.replace('%1', namePath).replace('%2', msgName); console.warn(warning); } diff --git a/core/contextmenu.js b/core/contextmenu.js index bcece8129..6c9186b12 100644 --- a/core/contextmenu.js +++ b/core/contextmenu.js @@ -222,8 +222,8 @@ Blockly.ContextMenu.blockDeleteOption = function(block) { descendantCount -= nextBlock.getDescendants(false).length; } var deleteOption = { - text: descendantCount == 1 ? Blockly.Msg.DELETE_BLOCK : - Blockly.Msg.DELETE_X_BLOCKS.replace('%1', String(descendantCount)), + text: descendantCount == 1 ? Blockly.Msg['DELETE_BLOCK'] : + Blockly.Msg['DELETE_X_BLOCKS'].replace('%1', String(descendantCount)), enabled: true, callback: function() { Blockly.Events.setGroup(true); @@ -244,7 +244,7 @@ Blockly.ContextMenu.blockHelpOption = function(block) { var url = goog.isFunction(block.helpUrl) ? block.helpUrl() : block.helpUrl; var helpOption = { enabled: !!url, - text: Blockly.Msg.HELP, + text: Blockly.Msg['HELP'], callback: function() { block.showHelp_(); } @@ -265,7 +265,7 @@ Blockly.ContextMenu.blockDuplicateOption = function(block) { enabled = false; } var duplicateOption = { - text: Blockly.Msg.DUPLICATE_BLOCK, + text: Blockly.Msg['DUPLICATE_BLOCK'], enabled: enabled, callback: function() { Blockly.duplicate_(block); @@ -287,13 +287,13 @@ Blockly.ContextMenu.blockCommentOption = function(block) { }; // If there's already a comment, add an option to delete it. if (block.comment) { - commentOption.text = Blockly.Msg.REMOVE_COMMENT; + commentOption.text = Blockly.Msg['REMOVE_COMMENT']; commentOption.callback = function() { block.setCommentText(null); }; } else { // If there's no comment, add an option to create a comment. - commentOption.text = Blockly.Msg.ADD_COMMENT; + commentOption.text = Blockly.Msg['ADD_COMMENT']; commentOption.callback = function() { block.setCommentText(''); }; diff --git a/core/field_textinput.js b/core/field_textinput.js index dfc6d9a50..41bbdbeea 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -173,7 +173,7 @@ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) { */ Blockly.FieldTextInput.prototype.showPromptEditor_ = function() { var fieldText = this; - Blockly.prompt(Blockly.Msg.CHANGE_VALUE_TITLE, this.text_, + Blockly.prompt(Blockly.Msg['CHANGE_VALUE_TITLE'], this.text_, function(newValue) { if (fieldText.sourceBlock_) { newValue = fieldText.callValidator(newValue); diff --git a/core/field_variable.js b/core/field_variable.js index a494ac411..255c67a0c 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -314,11 +314,11 @@ Blockly.FieldVariable.dropdownCreate = function() { // Set the UUID as the internal representation of the variable. options[i] = [variableModelList[i].name, variableModelList[i].getId()]; } - options.push([Blockly.Msg.RENAME_VARIABLE, Blockly.RENAME_VARIABLE_ID]); - if (Blockly.Msg.DELETE_VARIABLE) { + options.push([Blockly.Msg['RENAME_VARIABLE'], Blockly.RENAME_VARIABLE_ID]); + if (Blockly.Msg['DELETE_VARIABLE']) { options.push( [ - Blockly.Msg.DELETE_VARIABLE.replace('%1', name), + Blockly.Msg['DELETE_VARIABLE'].replace('%1', name), Blockly.DELETE_VARIABLE_ID ] ); diff --git a/core/procedures.js b/core/procedures.js index cf890a243..01f72dfd3 100644 --- a/core/procedures.js +++ b/core/procedures.js @@ -188,7 +188,7 @@ Blockly.Procedures.flyoutCategory = function(workspace) { block.setAttribute('type', 'procedures_defnoreturn'); block.setAttribute('gap', 16); var nameField = goog.dom.createDom('field', null, - Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE); + Blockly.Msg['PROCEDURES_DEFNORETURN_PROCEDURE']); nameField.setAttribute('name', 'NAME'); block.appendChild(nameField); xmlList.push(block); @@ -201,7 +201,7 @@ Blockly.Procedures.flyoutCategory = function(workspace) { block.setAttribute('type', 'procedures_defreturn'); block.setAttribute('gap', 16); var nameField = goog.dom.createDom('field', null, - Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE); + Blockly.Msg['PROCEDURES_DEFRETURN_PROCEDURE']); nameField.setAttribute('name', 'NAME'); block.appendChild(nameField); xmlList.push(block); diff --git a/core/utils.js b/core/utils.js index 6ab5c1de3..6ba9da683 100644 --- a/core/utils.js +++ b/core/utils.js @@ -39,19 +39,6 @@ goog.require('goog.math.Coordinate'); goog.require('goog.userAgent'); -/** - * To allow ADVANCED_OPTIMIZATIONS, combining variable.name and variable['name'] - * is not possible. To access the exported Blockly.Msg.Something it needs to be - * accessed through the exact name that was exported. Note, that all the exports - * are happening as the last thing in the generated js files, so they won't be - * accessible before JavaScript loads! - * @return {!Object.} The message array. - * @private - */ -Blockly.utils.getMessageArray_ = function() { - return goog.global['Blockly']['Msg']; -}; - /** * Remove an attribute from a element even if it's in IE 10. * Similar to Element.removeAttribute() but it works on SVG elements in IE 10. @@ -435,7 +422,7 @@ Blockly.utils.replaceMessageReferences = function(message) { Blockly.utils.checkMessageReferences = function(message) { var validSoFar = true; - var msgTable = Blockly.utils.getMessageArray_(); + var msgTable = Blockly.Msg; // TODO(#1169): Implement support for other string tables, prefixes other than BKY_. var regex = /%{(BKY_[A-Z][A-Z0-9_]*)}/gi; @@ -540,8 +527,8 @@ Blockly.utils.tokenizeInterpolation_ = function(message, // are defined in ../msgs/ files. var bklyKey = goog.string.startsWith(keyUpper, 'BKY_') ? keyUpper.substring(4) : null; - if (bklyKey && bklyKey in Blockly.utils.getMessageArray_()) { - var rawValue = Blockly.utils.getMessageArray_()[bklyKey]; + if (bklyKey && bklyKey in Blockly.Msg) { + var rawValue = Blockly.Msg[bklyKey]; if (goog.isString(rawValue)) { // Attempt to dereference substrings, too, appending to the end. Array.prototype.push.apply(tokens, diff --git a/core/variable_map.js b/core/variable_map.js index cf4609c55..f243b0358 100644 --- a/core/variable_map.js +++ b/core/variable_map.js @@ -230,7 +230,7 @@ Blockly.VariableMap.prototype.deleteVariableById = function(id) { if (block.type == 'procedures_defnoreturn' || block.type == 'procedures_defreturn') { var procedureName = block.getFieldValue('NAME'); - var deleteText = Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE. + var deleteText = Blockly.Msg['CANNOT_DELETE_VARIABLE_PROCEDURE']. replace('%1', variableName). replace('%2', procedureName); Blockly.alert(deleteText); @@ -241,7 +241,7 @@ Blockly.VariableMap.prototype.deleteVariableById = function(id) { var map = this; if (uses.length > 1) { // Confirm before deleting multiple blocks. - var confirmText = Blockly.Msg.DELETE_VARIABLE_CONFIRMATION. + var confirmText = Blockly.Msg['DELETE_VARIABLE_CONFIRMATION']. replace('%1', String(uses.length)). replace('%2', variableName); Blockly.confirm(confirmText, diff --git a/core/variables.js b/core/variables.js index dff68c30e..5644ad179 100644 --- a/core/variables.js +++ b/core/variables.js @@ -129,7 +129,7 @@ Blockly.Variables.allDeveloperVariables = function(workspace) { Blockly.Variables.flyoutCategory = function(workspace) { var xmlList = []; var button = goog.dom.createDom('button'); - button.setAttribute('text', Blockly.Msg.NEW_VARIABLE); + button.setAttribute('text', Blockly.Msg['NEW_VARIABLE']); button.setAttribute('callbackKey', 'CREATE_VARIABLE'); workspace.registerButtonCallback('CREATE_VARIABLE', function(button) { @@ -267,7 +267,7 @@ Blockly.Variables.createVariableButtonHandler = function( var type = opt_type || ''; // This function needs to be named so it can be called recursively. var promptAndCheckWithAlert = function(defaultName) { - Blockly.Variables.promptName(Blockly.Msg.NEW_VARIABLE_TITLE, defaultName, + Blockly.Variables.promptName(Blockly.Msg['NEW_VARIABLE_TITLE'], defaultName, function(text) { if (text) { var existing = @@ -275,10 +275,10 @@ Blockly.Variables.createVariableButtonHandler = function( if (existing) { var lowerCase = text.toLowerCase(); if (existing.type == type) { - var msg = Blockly.Msg.VARIABLE_ALREADY_EXISTS.replace( + var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS'].replace( '%1', lowerCase); } else { - var msg = Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE; + var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE']; msg = msg.replace('%1', lowerCase).replace('%2', existing.type); } Blockly.alert(msg, @@ -336,14 +336,14 @@ Blockly.Variables.renameVariable = function(workspace, variable, // This function needs to be named so it can be called recursively. var promptAndCheckWithAlert = function(defaultName) { var promptText = - Blockly.Msg.RENAME_VARIABLE_TITLE.replace('%1', variable.name); + Blockly.Msg['RENAME_VARIABLE_TITLE'].replace('%1', variable.name); Blockly.Variables.promptName(promptText, defaultName, function(newName) { if (newName) { var existing = Blockly.Variables.nameUsedWithOtherType_(newName, variable.type, workspace); if (existing) { - var msg = Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE + var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE'] .replace('%1', newName.toLowerCase()) .replace('%2', existing.type); Blockly.alert(msg, @@ -380,8 +380,8 @@ Blockly.Variables.promptName = function(promptText, defaultText, callback) { // Beyond this, all names are legal. if (newVar) { newVar = newVar.replace(/[\s\xa0]+/g, ' ').replace(/^ | $/g, ''); - if (newVar == Blockly.Msg.RENAME_VARIABLE || - newVar == Blockly.Msg.NEW_VARIABLE) { + if (newVar == Blockly.Msg['RENAME_VARIABLE'] || + newVar == Blockly.Msg['NEW_VARIABLE']) { // Ok, not ALL names are legal... newVar = null; } diff --git a/core/variables_dynamic.js b/core/variables_dynamic.js index 111e68b09..7cf3e6430 100644 --- a/core/variables_dynamic.js +++ b/core/variables_dynamic.js @@ -54,14 +54,14 @@ Blockly.VariablesDynamic.onCreateVariableButtonClick_Colour = function(button) { Blockly.VariablesDynamic.flyoutCategory = function(workspace) { var xmlList = []; var button = goog.dom.createDom('button'); - button.setAttribute('text', Blockly.Msg.NEW_STRING_VARIABLE); + button.setAttribute('text', Blockly.Msg['NEW_STRING_VARIABLE']); button.setAttribute('callbackKey', 'CREATE_VARIABLE_STRING'); xmlList.push(button); button = goog.dom.createDom('button'); - button.setAttribute('text', Blockly.Msg.NEW_NUMBER_VARIABLE); + button.setAttribute('text', Blockly.Msg['NEW_NUMBER_VARIABLE']); button.setAttribute('callbackKey', 'CREATE_VARIABLE_NUMBER'); xmlList.push(button);button = goog.dom.createDom('button'); - button.setAttribute('text', Blockly.Msg.NEW_COLOUR_VARIABLE); + button.setAttribute('text', Blockly.Msg['NEW_COLOUR_VARIABLE']); button.setAttribute('callbackKey', 'CREATE_VARIABLE_COLOUR'); xmlList.push(button); diff --git a/core/workspace_svg.js b/core/workspace_svg.js index fe7273e95..c5a73a27f 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -1193,12 +1193,12 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { // Options to undo/redo previous action. var undoOption = {}; - undoOption.text = Blockly.Msg.UNDO; + undoOption.text = Blockly.Msg['UNDO']; undoOption.enabled = this.undoStack_.length > 0; undoOption.callback = this.undo.bind(this, false); menuOptions.push(undoOption); var redoOption = {}; - redoOption.text = Blockly.Msg.REDO; + redoOption.text = Blockly.Msg['REDO']; redoOption.enabled = this.redoStack_.length > 0; redoOption.callback = this.undo.bind(this, true); menuOptions.push(redoOption); @@ -1206,7 +1206,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { // Option to clean up blocks. if (this.scrollbar) { var cleanOption = {}; - cleanOption.text = Blockly.Msg.CLEAN_UP; + cleanOption.text = Blockly.Msg['CLEAN_UP']; cleanOption.enabled = topBlocks.length > 1; cleanOption.callback = this.cleanUp.bind(this); menuOptions.push(cleanOption); @@ -1248,7 +1248,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { // Option to collapse top blocks. var collapseOption = {enabled: hasExpandedBlocks}; - collapseOption.text = Blockly.Msg.COLLAPSE_ALL; + collapseOption.text = Blockly.Msg['COLLAPSE_ALL']; collapseOption.callback = function() { toggleOption(true); }; @@ -1256,7 +1256,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { // Option to expand top blocks. var expandOption = {enabled: hasCollapsedBlocks}; - expandOption.text = Blockly.Msg.EXPAND_ALL; + expandOption.text = Blockly.Msg['EXPAND_ALL']; expandOption.callback = function() { toggleOption(false); }; @@ -1295,8 +1295,8 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { } var deleteOption = { - text: deleteList.length == 1 ? Blockly.Msg.DELETE_BLOCK : - Blockly.Msg.DELETE_X_BLOCKS.replace('%1', String(deleteList.length)), + text: deleteList.length == 1 ? Blockly.Msg['DELETE_BLOCK'] : + Blockly.Msg['DELETE_X_BLOCKS'].replace('%1', String(deleteList.length)), enabled: deleteList.length > 0, callback: function() { if (ws.currentGesture_) { @@ -1306,7 +1306,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { deleteNext(); } else { Blockly.confirm( - Blockly.Msg.DELETE_ALL_BLOCKS.replace('%1', deleteList.length), + Blockly.Msg['DELETE_ALL_BLOCKS'].replace('%1', deleteList.length), function(ok) { if (ok) { deleteNext(); diff --git a/demos/code/code.js b/demos/code/code.js index ed1d5209e..9a2d45c8e 100644 --- a/demos/code/code.js +++ b/demos/code/code.js @@ -538,7 +538,7 @@ Code.runJS = function() { Code.discard = function() { var count = Code.workspace.getAllBlocks().length; if (count < 2 || - window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace('%1', count))) { + window.confirm(Blockly.Msg['DELETE_ALL_BLOCKS'].replace('%1', count))) { Code.workspace.clear(); if (window.location.hash) { window.location.hash = ''; diff --git a/demos/graph/index.html b/demos/graph/index.html index e7c2b6a98..90628577c 100644 --- a/demos/graph/index.html +++ b/demos/graph/index.html @@ -196,9 +196,9 @@ Blockly.defineBlocksWithJsonArray([{ "type": "graph_get_x", "message0": "x", "output": "Number", - "colour": Blockly.Msg.VARIABLES_HUE, - "tooltip": Blockly.Msg.VARIABLES_GET_TOOLTIP, - "helpUrl": Blockly.Msg.VARIABLES_GET_HELPURL + "colour": Blockly.Msg['VARIABLES_HUE'], + "tooltip": Blockly.Msg['VARIABLES_GET_TOOLTIP'], + "helpUrl": Blockly.Msg['VARIABLES_GET_HELPURL'] }]); Blockly.JavaScript['graph_get_x'] = function(block) { @@ -216,9 +216,9 @@ Blockly.defineBlocksWithJsonArray([{ "check": "Number" } ], - "colour": Blockly.Msg.VARIABLES_HUE, - "tooltip": Blockly.Msg.VARIABLES_SET_TOOLTIP, - "helpUrl": Blockly.Msg.VARIABLES_SET_HELPURL + "colour": Blockly.Msg['VARIABLES_HUE'], + "tooltip": Blockly.Msg['VARIABLES_SET_TOOLTIP'], + "helpUrl": Blockly.Msg['VARIABLES_SET_HELPURL'] }]); Blockly.JavaScript['graph_set_y'] = function(block) { diff --git a/demos/plane/blocks.js b/demos/plane/blocks.js index 18be29c5d..8514b6f8c 100644 --- a/demos/plane/blocks.js +++ b/demos/plane/blocks.js @@ -26,11 +26,11 @@ Blockly.Blocks['plane_set_seats'] = { // Block seat variable setter. init: function() { - this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL); + this.setHelpUrl(Blockly.Msg['VARIABLES_SET_HELPURL']); this.setColour(330); this.appendValueInput('VALUE') .appendField(Plane.getMsg('Plane_setSeats')); - this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP); + this.setTooltip(Blockly.Msg['VARIABLES_SET_TOOLTIP']); this.setDeletable(false); } }; @@ -45,7 +45,7 @@ Blockly.JavaScript['plane_set_seats'] = function(block) { Blockly.Blocks['plane_get_rows'] = { // Block for row variable getter. init: function() { - this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL); + this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']); this.setColour(330); this.appendDummyInput() .appendField(Plane.getMsg('Plane_getRows'), 'title'); @@ -65,7 +65,7 @@ Blockly.JavaScript['plane_get_rows'] = function(block) { Blockly.Blocks['plane_get_rows1st'] = { // Block for first class row variable getter. init: function() { - this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL); + this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']); this.setColour(330); this.appendDummyInput() .appendField(Plane.getMsg('Plane_getRows1'), 'title'); @@ -85,7 +85,7 @@ Blockly.JavaScript['plane_get_rows1st'] = function(block) { Blockly.Blocks['plane_get_rows2nd'] = { // Block for second class row variable getter. init: function() { - this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL); + this.setHelpUrl(Blockly.Msg['VARIABLES_GET_HELPURL']); this.setColour(330); this.appendDummyInput() .appendField(Plane.getMsg('Plane_getRows2'), 'title'); diff --git a/i18n/create_messages.py b/i18n/create_messages.py index 2254b3012..3ff2fcf7c 100755 --- a/i18n/create_messages.py +++ b/i18n/create_messages.py @@ -42,7 +42,7 @@ def load_constants(filename): for key in constant_defs: value = constant_defs[key] value = value.replace('"', '\\"') - constants_text += u'\n/** @export */ Blockly.Msg.{0} = \"{1}\";'.format( + constants_text += u'\nBlockly.Msg["{0}"] = \"{1}\";'.format( key, value) return constants_text @@ -88,7 +88,7 @@ def main(): # Read in synonyms file, which must be output in every language. synonym_defs = read_json_file(os.path.join( os.curdir, args.source_synonym_file)) - synonym_text = '\n'.join([u'/** @export */ Blockly.Msg.{0} = Blockly.Msg.{1};' + synonym_text = '\n'.join([u'Blockly.Msg["{0}"] = Blockly.Msg["{1}"];' .format(key, synonym_defs[key]) for key in synonym_defs]) # Read in constants file, which must be output in every language. @@ -140,7 +140,7 @@ goog.require('Blockly.Msg'); value = source_defs[key] comment = ' // untranslated' value = value.replace('"', '\\"') - outfile.write(u'/** @export */ Blockly.Msg.{0} = "{1}";{2}\n' + outfile.write(u'Blockly.Msg["{0}"] = "{1}";{2}\n' .format(key, value, comment)) # Announce any keys defined only for target language. diff --git a/i18n/js_to_json.py b/i18n/js_to_json.py index e48b1cee1..06d36e9b5 100755 --- a/i18n/js_to_json.py +++ b/i18n/js_to_json.py @@ -48,10 +48,10 @@ import re from common import write_files -_INPUT_DEF_PATTERN = re.compile("""Blockly.Msg.(\w*)\s*=\s*'(.*)';?\r?$""") +_INPUT_DEF_PATTERN = re.compile("""Blockly.Msg\[(\w*)\]\s*=\s*'(.*)';?\r?$""") _INPUT_SYN_PATTERN = re.compile( - """Blockly.Msg.(\w*)\s*=\s*Blockly.Msg.(\w*);""") + """Blockly.Msg\[(\w*)\]\s*=\s*Blockly.Msg\[(\w*)\];""") _CONSTANT_DESCRIPTION_PATTERN = re.compile( """{{Notranslate}}""", re.IGNORECASE)