From bf7abee679a5022fd0f9ea43d6e8a0009a48d0f3 Mon Sep 17 00:00:00 2001 From: zochris Date: Sun, 13 Oct 2019 13:00:54 +0200 Subject: [PATCH] Rephrase "variable already exists" message The message now includes the name with casing of the already existing variable. --- core/variables.js | 8 +++++--- msg/messages.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/variables.js b/core/variables.js index 74ca01bf4..f5d7216c0 100644 --- a/core/variables.js +++ b/core/variables.js @@ -286,11 +286,12 @@ Blockly.Variables.createVariableButtonHandler = function( var lowerCase = text.toLowerCase(); if (existing.type == type) { var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS'].replace( - '%1', lowerCase); + '%1', lowerCase).replace('%2', existing.name); } else { var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE']; - msg = msg.replace('%1', lowerCase).replace('%2', existing.type); + msg = msg.replace('%1', lowerCase).replace('%2', existing.type) + .replace('%3', existing.name); } Blockly.alert(msg, function() { @@ -352,7 +353,8 @@ Blockly.Variables.renameVariable = function(workspace, variable, if (existing) { var msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE'] .replace('%1', newName.toLowerCase()) - .replace('%2', existing.type); + .replace('%2', existing.type) + .replace('%3', existing.name); Blockly.alert(msg, function() { promptAndCheckWithAlert(newName); // Recurse diff --git a/msg/messages.js b/msg/messages.js index 2cb5c3ed8..a56e5ae3c 100644 --- a/msg/messages.js +++ b/msg/messages.js @@ -172,10 +172,10 @@ Blockly.Msg.NEW_VARIABLE_TYPE_TITLE = 'New variable type:'; Blockly.Msg.NEW_VARIABLE_TITLE = 'New variable name:'; /** @type {string} */ /// alert - Tells the user that the name they entered is already in use. -Blockly.Msg.VARIABLE_ALREADY_EXISTS = 'A variable named "%1" already exists.'; +Blockly.Msg.VARIABLE_ALREADY_EXISTS = 'A variable named "%1" already exists (as "%2").'; /** @type {string} */ /// alert - Tells the user that the name they entered is already in use for another type. -Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE = 'A variable named "%1" already exists for another type: "%2".'; +Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE = 'A variable named "%1" already exists for another type: "%2" (as "%3").'; // Variable deletion. /** @type {string} */