Skip to content

Commit

Permalink
Fix math_change block in Pond. Add Brezhoneg, Bahasa Indonesia, and P…
Browse files Browse the repository at this point in the history
…ortuguês.
  • Loading branch information
NeilFraser committed Mar 26, 2016
1 parent 4f9adeb commit 41fbdd7
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 82 deletions.
10 changes: 5 additions & 5 deletions appengine/common/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

// Supported languages (consistent across all apps).
window['BlocklyGamesLanguages'] = [
'ar', 'be-tarask', 'br', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es',
'eu', 'fa', 'fi', 'fr', 'gl', 'he', 'hrx', 'hu', 'ia', 'is', 'it',
'ja', 'ko', 'lt', 'lv', 'mk', 'ms', 'nb', 'nl', 'pl', 'pms', 'pt-br',
'ro', 'ru', 'sc', 'sco', 'sk', 'sr', 'sv', 'ta', 'th', 'tr', 'uk',
'vi', 'zh-hans', 'zh-hant'
'ar', 'be-tarask', 'br', 'ca', 'cs', 'da', 'de', 'bg', 'el', 'en',
'es', 'eu', 'fa', 'fi', 'fr', 'gl', 'he', 'hrx', 'hu', 'ia', 'id',
'is', 'it', 'ja', 'ko', 'lt', 'lv', 'mk', 'ms', 'nb', 'nl', 'pl',
'pms', 'pt', 'pt-br', 'ro', 'ru', 'sc', 'sco', 'sk', 'sr', 'sv',
'ta', 'th', 'tr', 'uk', 'vi', 'zh-hans', 'zh-hant'
];

// Use a series of heuristics that determine the likely language of this user.
Expand Down
2 changes: 1 addition & 1 deletion appengine/js/lib-games.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BlocklyGames.LANGUAGE_NAME = {
'ar': 'العربية',
'az': 'Azərbaycanca',
'be-tarask': 'Taraškievica',
'bg': 'български език',
'br': 'Brezhoneg',
'ca': 'Català',
'cdo': '閩東語',
Expand Down Expand Up @@ -99,7 +100,6 @@ BlocklyGames.LANGUAGE_NAME = {
'ta': 'தமிழ்',
'th': 'ภาษาไทย',
'tl': 'Tagalog',
'tlh': 'tlhIngan Hol',
'tr': 'Türkçe',
'uk': 'Українська',
'vi': 'Tiếng Việt',
Expand Down
148 changes: 81 additions & 67 deletions appengine/pond/js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ Blockly.Blocks['pond_scan'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendValueInput('DEGREE')
.setCheck(['Number', 'Angle'])
.appendField('scan(');
//this.appendValueInput('RESOLUTION')
// .setCheck('Number')
// .appendField(',');
this.appendDummyInput()
.appendField(')');
this.setInputsInline(true);
this.setOutput(true, 'Number');
this.setTooltip(BlocklyGames.getMsg('Pond_scanTooltip'));
this.jsonInit({
"message0": "scan(%1)",
"args0": [
{
"type": "input_value",
"name": "DEGREE",
"check": ["Number", "Angle"]
}
],
"inputsInline": true,
"output": "Number",
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_scanTooltip')
});
}
};

Expand All @@ -79,19 +81,26 @@ Blockly.Blocks['pond_cannon'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendValueInput('DEGREE')
.setCheck(['Number', 'Angle'])
.appendField('cannon(');
this.appendValueInput('RANGE')
.setCheck('Number')
.appendField(',');
this.appendDummyInput()
.appendField(');');
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(BlocklyGames.getMsg('Pond_cannonTooltip'));
this.jsonInit({
"message0": "cannon(%1, %2);",
"args0": [
{
"type": "input_value",
"name": "DEGREE",
"check": ["Number", "Angle"]
},
{
"type": "input_value",
"name": "RANGE",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_cannonTooltip')
});
}
};

Expand All @@ -110,19 +119,21 @@ Blockly.Blocks['pond_swim'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendValueInput('DEGREE')
.setCheck(['Number', 'Angle'])
.appendField('swim(');
//this.appendValueInput('SPEED')
// .setCheck('Number')
// .appendField(',');
this.appendDummyInput()
.appendField(');');
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(BlocklyGames.getMsg('Pond_swimTooltip'));
this.jsonInit({
"message0": "swim(%1);",
"args0": [
{
"type": "input_value",
"name": "DEGREE",
"check": ["Number", "Angle"]
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_swimTooltip')
});
}
};

Expand All @@ -141,12 +152,13 @@ Blockly.Blocks['pond_stop'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendDummyInput()
.appendField('stop();');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(BlocklyGames.getMsg('Pond_stopTooltip'));
this.jsonInit({
"message0": "stop();",
"previousStatement": null,
"nextStatement": null,
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_stopTooltip')
});
}
};

Expand All @@ -161,11 +173,12 @@ Blockly.Blocks['pond_health'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendDummyInput()
.appendField('health()');
this.setOutput(true, 'Number');
this.setTooltip(BlocklyGames.getMsg('Pond_healthTooltip'));
this.jsonInit({
"message0": "health()",
"output": "Number",
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_healthTooltip')
});
}
};

Expand All @@ -180,11 +193,12 @@ Blockly.Blocks['pond_speed'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendDummyInput()
.appendField('speed()');
this.setOutput(true, 'Number');
this.setTooltip(BlocklyGames.getMsg('Pond_speedTooltip'));
this.jsonInit({
"message0": "speed()",
"output": "Number",
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_speedTooltip')
});
}
};

Expand All @@ -199,11 +213,12 @@ Blockly.Blocks['pond_loc_x'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendDummyInput()
.appendField('loc_x()');
this.setOutput(true, 'Number');
this.setTooltip(BlocklyGames.getMsg('Pond_locXTooltip'));
this.jsonInit({
"message0": "loc_x()",
"output": "Number",
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_locXTooltip')
});
}
};

Expand All @@ -218,11 +233,12 @@ Blockly.Blocks['pond_loc_y'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(290);
this.appendDummyInput()
.appendField('loc_y()');
this.setOutput(true, 'Number');
this.setTooltip(BlocklyGames.getMsg('Pond_locYTooltip'));
this.jsonInit({
"message0": "loc_y()",
"output": "Number",
"colour": 290,
"tooltip": BlocklyGames.getMsg('Pond_locYTooltip')
});
}
};

Expand Down Expand Up @@ -584,9 +600,7 @@ Blockly.Blocks['pond_math_change'] = {
return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace('%1',
thisBlock.getFieldValue('VAR'));
});
},
getVars: Blockly.Blocks['math_change'].getVars,
renameVar: Blockly.Blocks['math_change'].renameVar
}
};

Blockly.JavaScript['pond_math_change'] = Blockly.JavaScript['math_change'];
Expand Down
4 changes: 2 additions & 2 deletions appengine/template.soy
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<span id="Games_xmlError">{msg meaning="Games.xmlError" desc="alert - There was a problem loading a file previously saved by the user. The most likely reason for the problem is that it was created with an earlier, incompatible version of Blockly. This message will be followed by technical information useful to engineers trying to understand the problem."}Could not load your saved file. Perhaps it was created with a different version of Blockly?{/msg}</span>

// Default variable names.
<span id="Games_listVariable">{msg meaning="Games.listVariable" desc="variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Lists list]. This should be a single word, preferably short."}list{/msg}</span>
<span id="Games_textVariable">{msg meaning="Games.textVariable" desc="variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Text piece of text]. This should be a single word, preferably short."}text{/msg}</span>
<span id="Games_listVariable">{{msg meaning="Games.listVariable" desc="variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Lists list]. This should be a single word, preferably short.\n{lb}{lb}Identical|List{rb}{rb}"}}list{{/msg}}</span>
<span id="Games_textVariable">{{msg meaning="Games.textVariable" desc="variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Text piece of text]. This should be a single word, preferably short.\n{lb}{lb}Identical|Text{rb}{rb}"}}text{{/msg}}</span>
</div>
{/template}

Expand Down
23 changes: 18 additions & 5 deletions i18n/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ def get_prefix_counts(filename):
prefixes = {}
f = open(filename)
keys = json.load(f)
total = 0
for key in keys:
prefix = key.split('.')[0]
prefixes[prefix] = prefixes.get(prefix, 0) + 1
if prefix != '@metadata':
prefixes[prefix] = prefixes.get(prefix, 0) + 1
total += 1
f.close()
prefixes['ALL'] = total
return prefixes


Expand Down Expand Up @@ -91,8 +95,12 @@ def generateNumberAsPercent(num, total):
'%)</font>')

apps = prefix_counts[TOTAL].keys()
print("<SCRIPT LANGUAGE='JavaScript1.2' SRC='https://neil.fraser.name/"
"software/tablesort/tablesort-min.js'></SCRIPT>")
apps.remove('ALL')
apps.sort()
apps.append('ALL')
print('<html><body>')
print('<SCRIPT SRC="https://neil.fraser.name/'
'software/tablesort/tablesort-min.js"></SCRIPT>')
print('<table cellspacing=5><thead><tr>')
print('<th class=nocase>Language</th><th class=num>' +
'</th><th class=num>'.join(apps) + '</th></tr></thead><tbody>')
Expand All @@ -108,6 +116,7 @@ def generateNumberAsPercent(num, total):
print('</tbody><tfoot><tr><td>ALL</td><td>')
print('</td><td>'.join([str(prefix_counts[TOTAL][app]) for app in apps]))
print('</td></tr></tfoot></table>')
print('</body></html>')


def output_as_text(prefix_counts):
Expand All @@ -125,6 +134,9 @@ def generate_number_as_percent(num, total):
MAX_WIDTH = len('999 (100%)') + 1
FIELD_STRING = '{0: <' + str(MAX_WIDTH) + '}'
apps = prefix_counts[TOTAL].keys()
apps.remove('ALL')
apps.sort()
apps.append('ALL')
print(FIELD_STRING.format('Language') + ''.join(
[FIELD_STRING.format(app) for app in apps]))
print(('-' * (MAX_WIDTH - 1) + ' ') * (len(apps) + 1))
Expand All @@ -134,7 +146,7 @@ def generate_number_as_percent(num, total):
''.join([FIELD_STRING.format(generate_number_as_percent(
prefix_counts[lang].get(app, 0),
prefix_counts[TOTAL][app])) for app in apps]))
print(FIELD_STRING.format(TOTAL) +
print(FIELD_STRING.format('ALL') +
''.join(
[FIELD_STRING.format(prefix_counts[TOTAL][app])
for app in apps]))
Expand All @@ -144,7 +156,8 @@ def main():
"""Processes input files and outputs results in specified format.
"""
# Argument parsing.
parser = argparse.ArgumentParser(description='Compare JSON files.')
parser = argparse.ArgumentParser(description=
'Produce a table showing the translation status of each app by language.')
parser.add_argument('--key_file', default='keys.json',
help='file with complete list of keys.')
parser.add_argument('--output', default='text', choices=['text', 'html'],
Expand Down
4 changes: 2 additions & 2 deletions json/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"Games.linkAlert": "alert - After the user has pressed a button to save his/her program, this provides the URL (%1) to retrieve the program. The characters '\n\n' indicate that a blank line will be displayed before the URL (in English). Leave those in unless you move %1 to the beginning or middle of the text, in which case you should use your judgment about where blank lines would be most useful.\n\nParameters:\n* %1 - URL of saved program.",
"Games.hashError": "alert - A request to retrieve a stored program does not have a valid URL. %1 is the invalid portion of the URL.",
"Games.xmlError": "alert - There was a problem loading a file previously saved by the user. The most likely reason for the problem is that it was created with an earlier, incompatible version of Blockly. This message will be followed by technical information useful to engineers trying to understand the problem.",
"Games.listVariable": "variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Lists list]. This should be a single word, preferably short.",
"Games.listVariable": "variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Lists list]. This should be a single word, preferably short.\n{{Identical|List}}",
"Games.textVariable": "variable name - Default [https://github.com/google/blockly/wiki/Variables variable] representing a [https://github.com/google/blockly/wiki/Text piece of text]. This should be a single word, preferably short.\n{{Identical|Text}}",
"Games.congratulations": "alert - This is displayed when the user solves the level.\n{{Identical|Congratulation}}",
"Games.helpAbort": "callout - This dialog gives the user the option to skip this level.",
Expand Down Expand Up @@ -229,5 +229,5 @@
"Pond.rookName": "Name for a player that behaves like a rook (castle) in chess.\n{{Identical|Rook}}",
"Pond.sniperName": "Name for a player that hides in a corner and shoots.\n{{Identical|Sniper}}",
"Pond.breakLink": "Warning dialog. Options are 'OK' and 'Cancel'.",
"Pond.blocks": "Label on a tab that contains blocks editor.\n{{Identical|Block}}"
"Pond.blocks": "Label on a tab that contains blocks editor.\n{{Identical|Blocks}}"
}

0 comments on commit 41fbdd7

Please sign in to comment.