Commit 77d9970b authored by Beka Westberg's avatar Beka Westberg Committed by Evan W. Patton

Translate global variable typeblock names

parent c93be3f6
...@@ -401,55 +401,38 @@ Blockly.TypeBlock.prototype.loadProcedures_ = function(){ ...@@ -401,55 +401,38 @@ Blockly.TypeBlock.prototype.loadProcedures_ = function(){
* example of how to call this function. * example of how to call this function.
*/ */
Blockly.TypeBlock.prototype.loadGlobalVariables_ = function () { Blockly.TypeBlock.prototype.loadGlobalVariables_ = function () {
//clean up any previous procedures in the list // Remove any global vars from the list so that we can re-add them.
this.TBOptions_ = goog.object.filter(this.TBOptions_, this.TBOptions_ = goog.object.filter(this.TBOptions_, function(option) {
function(opti){ return !opti.isGlobalvar;}); return !option.isGlobalvar;
var globalVarNames = createTypeBlockForVariables_.call(this);
var self = this;
goog.array.forEach(globalVarNames, function(varName){
var canonicalN;
if (varName.translatedName.substring(0,3) === 'get')
canonicalN = 'lexical_variable_get';
else
canonicalN = 'lexical_variable_set';
self.TBOptions_[varName.translatedName] = {
canonicName: canonicalN,
dropDown: varName.dropDown,
isGlobalvar: true
};
}); });
/** var globalVarNames = Blockly.FieldLexicalVariable.getGlobalNames();
* Create TypeBlock options for global variables (a setter and a getter for each). goog.array.forEach(globalVarNames, function(varName) {
* @returns {Array} array of global var options var prefixedName = Blockly.Msg.LANG_VARIABLES_GLOBAL_PREFIX +
*/ ' ' + varName;
function createTypeBlockForVariables_() { var translatedGet = Blockly.Msg.LANG_VARIABLES_GET_TITLE_GET +
var options = []; ' ' + prefixedName;
var varNames = Blockly.FieldLexicalVariable.getGlobalNames(); // We can leave 'global' as 'global' inside the value property because
// Make a setter and a getter for each of the names // (I believe) the FieldLexicalVariable translates that later.
goog.array.forEach(varNames, function(varName){ this.TBOptions_[translatedGet] = {
options.push( canonicName: 'lexical_variable_get',
{
translatedName: 'get global ' + varName,
dropDown: { dropDown: {
titleName: 'VAR', titleName: 'VAR',
value: 'global ' + varName value: 'global ' + varName
} },
} isGlobalvar: true
); };
options.push( var translatedSet = Blockly.Msg.LANG_VARIABLES_SET_TITLE_SET +
{ ' ' + prefixedName;
translatedName: 'set global ' + varName, this.TBOptions_[translatedSet] = {
canonicName: 'lexical_variable_set',
dropDown: { dropDown: {
titleName: 'VAR', titleName: 'VAR',
value: 'global ' + varName value: 'global ' + varName
},
isGlobalvar: true
} }
} }.bind(this));
);
});
return options;
}
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment