- Allows use of Blockly's messaging format for category name, colour,… (#1028)

...in toolbox XML.
- Updated code editor demo to use this message format
- Re-built blockly_compressed.js
This commit is contained in:
vicng
2017-04-07 15:32:50 -07:00
committed by GitHub
parent dfc50ba843
commit ae2aaa2159
4 changed files with 49 additions and 30 deletions

View File

@@ -383,10 +383,22 @@ Code.init = function() {
};
window.addEventListener('resize', onresize, false);
// Interpolate translated messages into toolbox.
// The toolbox XML specifies each category name using Blockly's messaging
// format (eg. `<category name="%{BKY_CATLOGIC}">`).
// These message keys need to be defined in `Blockly.Msg` in order to
// be decoded by the library. Therefore, we'll use the `MSG` dictionary that's
// been defined for each language to import each category name message
// into `Blockly.Msg`.
// TODO: Clean up the message files so this is done explicitly instead of
// through this for-loop.
for (var messageKey in MSG) {
if (messageKey.startsWith('cat')) {
Blockly.Msg[messageKey.toUpperCase()] = MSG[messageKey];
}
}
// Construct the toolbox XML.
var toolboxText = document.getElementById('toolbox').outerHTML;
toolboxText = toolboxText.replace(/{(\w+)}/g,
function(m, p1) {return MSG[p1];});
var toolboxXml = Blockly.Xml.textToDom(toolboxText);
Code.workspace = Blockly.inject('content_blocks',