Skip to content

Commit 27416cb

Browse files
committed
Added Sphero SPRK translation integration.
Fixed example and template files for former renaming.
1 parent 6a6d661 commit 27416cb

File tree

13 files changed

+99
-54
lines changed

13 files changed

+99
-54
lines changed

build/cwc/main-debug.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ closureBuilder.build({
3131
'gensoyfiles/**/!(*_test).js',
3232
'!src/{blocks,blocks/**.js}',
3333
'!src/{frameworks,frameworks/**.js}',
34-
'../coding-with-chrome-libraries/src/**/!(*_test).js',
35-
// 'third_party/coding-with-chrome-libraries/src/**/!(*_test).js',
34+
'third_party/coding-with-chrome-libraries/src/**/!(*_test).js',
3635
]),
3736
externs: [
3837
'build/externs/blockly.js',

locales/eng/blocks/blocks.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,33 @@
2020
/* eslint-disable max-len */
2121
Locales['eng']['BLOCKS'] = {
2222
'ALL': 'all',
23+
'AND': 'and',
2324
'AS': 'as',
2425
'CHANGE': 'change',
26+
'CLEAR_DISPLAY': 'clear_display',
2527
'DEFINE': 'define',
2628
'DESTROY': 'destroy',
29+
'DISABLE': 'disable',
30+
'DISPLAY_TEXT': 'display text',
2731
'DO': 'do',
2832
'DOWN': 'down',
33+
'ENABLE': 'enable',
2934
'GROUP': 'group',
3035
'HEIGHT': 'height',
36+
'IMMEDIATELY': 'immediately',
3137
'IN': 'in',
3238
'KILL': 'kill',
3339
'LEFT': 'left',
3440
'LISTS': 'Lists',
3541
'PADDING': 'padding',
42+
'REPEAT_FOREVER': 'repeat_forever',
3643
'RIGHT': 'right',
44+
'SEC': 'sec.',
3745
'SET': 'set',
3846
'TO': 'to',
3947
'UP': 'up',
48+
'WAIT': 'wait',
49+
'WHEN_FINISHED': 'when finished',
4050
'WIDTH': 'width',
51+
'WITH': 'with',
4152
};

locales/eng/blocks/robot_blocks.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @fileoverview Translation file for robot blocks (english).
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
/* eslint-disable max-len */
21+
Locales['eng']['BLOCKS_ROBOT'] = {
22+
'HEADING': 'heading',
23+
'ON_COLLISION': 'on collision',
24+
'ON_POSITION_CHANGE': 'on position change',
25+
'RESET_ROBOT': 'reset robot',
26+
'ROLL_FOR': 'roll for',
27+
'ROLL_WITH': 'roll with',
28+
'ROTATE': 'rotate',
29+
'SET_BACKLIGHT': 'set backlight',
30+
'SET_BLINK': 'set blink',
31+
'SET_COLOR': 'set color',
32+
'SET_HEADING': 'set heading',
33+
'SET_SPEED': 'set speed',
34+
'SET_STABILIZATION': 'set stabilization',
35+
'SPEED': 'speed',
36+
'START': 'Program Start',
37+
'STOP_MOTORS': 'stop motors',
38+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"deploy": "npm test && git push",
8080
"depswriter": "python third_party/closure-library/closure/bin/build/depswriter.py --root_with_prefix=\"src/ ../../../../src/\"",
8181
"documentation": "jsdoc src -r -c documentation.json -d docs",
82-
"launch": "echo Lauching app. Please wait ... && npm run launch:linux --silent || npm run launch:mac --silent || npm run launch:win --silent",
82+
"launch": "echo Lauching app. Please wait ... && npm run launch:linux --silent || npm run launch:mac --silent || npm run launch:win-experimental --silent",
8383
"launch:linux": "google-chrome --load-and-launch:app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
8484
"launch:mac": "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --load-and-launch:app=$PWD/dist/chrome_os --enable-logging --v=1 --no-first-run",
8585
"launch:nw": "nw dist/nw_app",

src/blocks/general/blocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Blockly.Blocks['general_infinity_loop'] = {
2727
this.setHelpUrl('');
2828
this.setColour(120);
2929
this.appendDummyInput()
30-
.appendField(i18t('repeat forever'));
30+
.appendField(i18t('@@BLOCKS__REPEAT_FOREVER'));
3131
this.appendStatementInput('CODE')
3232
.setAlign(Blockly.ALIGN_CENTRE);
3333
this.setPreviousStatement(true);

src/blocks/general/messenger/blocks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Blockly.Blocks['general_messenger_delay'] = {
2828
this.setColour(260);
2929
this.appendDummyInput()
3030
.appendField(Blockly.BlocksTemplate.point())
31-
.appendField(i18t('wait ('))
31+
.appendField(i18t('@@BLOCKS__WAIT'))
3232
.appendField(new Blockly.FieldTextInput('2'), 'time')
33-
.appendField('sec)');
33+
.appendField(i18t('@@BLOCKS__SEC'));
3434
this.setPreviousStatement(true);
3535
this.setNextStatement(true);
3636
this.setTooltip(i18t('Delay actions for the given seconds'));
@@ -46,7 +46,7 @@ Blockly.Blocks['general_messenger_display_text'] = {
4646
this.setColour(150);
4747
this.appendValueInput('text')
4848
.appendField(Blockly.BlocksTemplate.addCircle())
49-
.appendField(i18t('display text'))
49+
.appendField(i18t('@@BLOCKS__DISPLAY_TEXT'))
5050
.setCheck('String');
5151
this.setPreviousStatement(true);
5252
this.setNextStatement(true);
@@ -64,7 +64,7 @@ Blockly.Blocks['general_messenger_display_clear'] = {
6464
this.setColour(150);
6565
this.appendDummyInput()
6666
.appendField(Blockly.BlocksTemplate.addCircle())
67-
.appendField(i18t('clear display'));
67+
.appendField(i18t('@@BLOCKS__CLEAR_DISPLAY'));
6868
this.setPreviousStatement(true);
6969
this.setNextStatement(true);
7070
this.setTooltip('');

src/blocks/sphero/sprk_plus/blocks.js

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Blockly.Blocks['sphero_sprk_plus_start'] = {
2929
this.setColour(65);
3030
this.appendDummyInput()
3131
.appendField(Blockly.BlocksTemplate.runningMan())
32-
.appendField(i18t('Programm Start'));
32+
.appendField(i18t('@@BLOCKS_ROBOT__START'));
3333
this.setNextStatement(true);
3434
this.setTooltip(i18t('Defines the start of the program'));
3535
},
@@ -45,8 +45,9 @@ Blockly.Blocks['sphero_sprk_plus_roll'] = {
4545
this.setColour(260);
4646
this.appendValueInput('speed').setCheck('Number')
4747
.appendField(Blockly.BlocksTemplate.point())
48-
.appendField(i18t('roll speed('));
49-
this.appendDummyInput().appendField(')');
48+
.appendField(i18t('@@BLOCKS_ROBOT__ROLL_WITH'));
49+
this.appendDummyInput()
50+
.appendField(i18t('@@BLOCKS_ROBOT__SPEED'));
5051
this.setPreviousStatement(true);
5152
this.setNextStatement(true);
5253
this.setTooltip(i18t('Move the Sphero in a direction'));
@@ -63,11 +64,12 @@ Blockly.Blocks['sphero_sprk_plus_roll_step'] = {
6364
this.setColour(260);
6465
this.appendValueInput('speed').setCheck('Number')
6566
.appendField(Blockly.BlocksTemplate.point())
66-
.appendField(i18t('roll with'));
67+
.appendField(i18t('@@BLOCKS_ROBOT__ROLL_WITH'));
6768
this.appendValueInput('heading')
68-
.appendField(i18t('speed and'));
69+
.appendField(i18t('@@BLOCKS_ROBOT__SPEED'))
70+
.appendField(i18t('@@BLOCKS__AND'));
6971
this.appendDummyInput()
70-
.appendField(i18t('heading'));
72+
.appendField(i18t('@@BLOCKS_ROBOT__HEADING'));
7173
this.setPreviousStatement(true);
7274
this.setNextStatement(true);
7375
this.setTooltip(i18t('Move the Sphero in a direction'));
@@ -84,13 +86,15 @@ Blockly.Blocks['sphero_sprk_plus_roll_time'] = {
8486
this.setColour(260);
8587
this.appendValueInput('time').setCheck('Number')
8688
.appendField(Blockly.BlocksTemplate.point())
87-
.appendField(i18t('roll for'));
89+
.appendField(i18t('@@BLOCKS_ROBOT__ROLL_FOR'));
8890
this.appendValueInput('speed').setCheck('Number')
89-
.appendField(i18t('sec with'));
91+
.appendField(i18t('@@BLOCKS__SEC'))
92+
.appendField(i18t('@@BLOCKS__WITH'));
9093
this.appendValueInput('heading')
91-
.appendField(i18t('speed and'));
94+
.appendField(i18t('@@BLOCKS_ROBOT__SPEED'))
95+
.appendField(i18t('@@BLOCKS__AND'));
9296
this.appendDummyInput()
93-
.appendField(i18t('heading'));
97+
.appendField(i18t('@@BLOCKS_ROBOT__HEADING'));
9498
this.setPreviousStatement(true);
9599
this.setNextStatement(true);
96100
this.setTooltip(
@@ -108,11 +112,11 @@ Blockly.Blocks['sphero_sprk_plus_rotate_time'] = {
108112
this.setColour(260);
109113
this.appendDummyInput()
110114
.appendField(Blockly.BlocksTemplate.point())
111-
.appendField(i18t('rotate'))
115+
.appendField(i18t('@@BLOCKS_ROBOT__ROTATE'))
112116
.appendField(new Blockly.FieldAngle(0), 'heading')
113-
.appendField(i18t('for'));
117+
.appendField(i18t('@@BLOCKS__FOR'));
114118
this.appendValueInput('time').setCheck('Number')
115-
.appendField(i18t('sec'));
119+
.appendField(i18t('@@BLOCKS__SEC'));
116120
this.setPreviousStatement(true);
117121
this.setNextStatement(true);
118122
this.setTooltip(
@@ -154,10 +158,10 @@ Blockly.Blocks['sphero_sprk_plus_stabilization'] = {
154158
this.setColour(260);
155159
this.appendDummyInput()
156160
.appendField(Blockly.BlocksTemplate.point())
157-
.appendField(i18t('set stabilization('))
161+
.appendField(i18t('@@BLOCKS_ROBOT__SET_STABILIZATION'))
158162
.appendField(new Blockly.FieldDropdown([
159-
[i18t('enable'), 'enable'],
160-
[i18t('disable'), 'disable'],
163+
[i18t('@@BLOCKS__ENABLE'), 'enable'],
164+
[i18t('@@BLOCKS__DISABLE'), 'disable'],
161165
]), 'enable')
162166
.appendField(')');
163167
this.setPreviousStatement(true);
@@ -177,9 +181,7 @@ Blockly.Blocks['sphero_sprk_plus_heading'] = {
177181
this.appendValueInput('heading')
178182
.setCheck('Number')
179183
.appendField(Blockly.BlocksTemplate.point())
180-
.appendField(i18t('set heading('));
181-
this.appendDummyInput()
182-
.appendField(')');
184+
.appendField(i18t('@@BLOCKS_ROBOT__SET_HEADING'));
183185
this.setPreviousStatement(true);
184186
this.setNextStatement(true);
185187
this.setTooltip(i18t('Sets Sphero heading.'));
@@ -197,9 +199,8 @@ Blockly.Blocks['sphero_sprk_plus_speed'] = {
197199
this.appendValueInput('speed')
198200
.setCheck('Number')
199201
.appendField(Blockly.BlocksTemplate.point())
200-
.appendField(i18t('set speed('))
201-
.appendField(new Blockly.FieldAngle(0), 'speed')
202-
.appendField(')');
202+
.appendField(i18t('@@BLOCKS_ROBOT__SET_SPEED'))
203+
.appendField(new Blockly.FieldAngle(0), 'speed');
203204
this.setPreviousStatement(true);
204205
this.setNextStatement(true);
205206
this.setTooltip(i18t('Sets Sphero speed.'));
@@ -216,8 +217,7 @@ Blockly.Blocks['sphero_sprk_plus_rgb'] = {
216217
this.setColour(260);
217218
this.appendValueInput('colour')
218219
.appendField(Blockly.BlocksTemplate.point())
219-
.appendField(i18t('set color ('));
220-
this.appendDummyInput().appendField(')');
220+
.appendField(i18t('@@BLOCKS_ROBOT__SET_COLOR'));
221221
this.setPreviousStatement(true);
222222
this.setNextStatement(true);
223223
this.setTooltip(i18t('Sets the leds on the Sphero ball.'));
@@ -234,8 +234,7 @@ Blockly.Blocks['sphero_sprk_plus_blink'] = {
234234
this.setColour(260);
235235
this.appendValueInput('colour')
236236
.appendField(Blockly.BlocksTemplate.point())
237-
.appendField(i18t('set color blink ('));
238-
this.appendDummyInput().appendField(')');
237+
.appendField(i18t('@@BLOCKS_ROBOT__SET_BLINK'));
239238
this.setPreviousStatement(true);
240239
this.setNextStatement(true);
241240
this.setTooltip(i18t('Sets the leds on the Sphero ball.'));
@@ -252,10 +251,9 @@ Blockly.Blocks['sphero_sprk_plus_backlight'] = {
252251
this.setColour(260);
253252
this.appendDummyInput()
254253
.appendField(Blockly.BlocksTemplate.point())
255-
.appendField(i18t('set backlight ('))
254+
.appendField(i18t('@@BLOCKS_ROBOT__SET_BACKLIGHT'))
256255
.appendField(new Blockly.FieldTextInput('254'), 'brightness')
257-
.appendField('(0 - 254)')
258-
.appendField(')');
256+
.appendField('(0 - 254)');
259257
this.setPreviousStatement(true);
260258
this.setNextStatement(true);
261259
this.setTooltip(i18t('Sets the back-light on the Sphero ball.'));
@@ -272,10 +270,10 @@ Blockly.Blocks['sphero_sprk_plus_stop'] = {
272270
this.setColour(260);
273271
this.appendDummyInput()
274272
.appendField(Blockly.BlocksTemplate.point())
275-
.appendField(i18t('stop motors('))
273+
.appendField(i18t('@@BLOCKS_ROBOT__STOP_MOTORS'))
276274
.appendField(new Blockly.FieldDropdown([
277-
[i18t('when finished'), 'when finished'],
278-
[i18t('immediately'), 'immediately'],
275+
[i18t('@@BLOCKS__IMMEDIATELY'), 'when finished'],
276+
[i18t('@@BLOCKS__WHEN_FINISHED'), 'immediately'],
279277
]), 'immediately')
280278
.appendField(')');
281279
this.setPreviousStatement(true);
@@ -294,7 +292,7 @@ Blockly.Blocks['sphero_sprk_plus_reset'] = {
294292
this.setColour(150);
295293
this.appendDummyInput()
296294
.appendField(Blockly.BlocksTemplate.addCircle())
297-
.appendField(i18t('reset device'));
295+
.appendField(i18t('@@BLOCKS_ROBOT__RESET_ROBOT'));
298296
this.setPreviousStatement(true);
299297
this.setNextStatement(true);
300298
this.setTooltip('');
@@ -312,7 +310,7 @@ Blockly.Blocks['sphero_sprk_plus_collision'] = {
312310
this.setColour(260);
313311
this.appendDummyInput()
314312
.appendField(Blockly.BlocksTemplate.point())
315-
.appendField(i18t('on collision'));
313+
.appendField(i18t('@@BLOCKS_ROBOT__ON_COLLISION'));
316314
this.appendStatementInput('CODE')
317315
.appendField(i18t('@@BLOCKS__DO'))
318316
.setAlign(Blockly.ALIGN_CENTRE);
@@ -332,7 +330,7 @@ Blockly.Blocks['sphero_sprk_plus_position_change'] = {
332330
this.setColour(260);
333331
this.appendDummyInput()
334332
.appendField(Blockly.BlocksTemplate.point())
335-
.appendField(i18t('on position change'));
333+
.appendField(i18t('@@BLOCKS_ROBOT__ON_POSITION_CHANGE'));
336334
this.appendStatementInput('CODE')
337335
.appendField(i18t('@@BLOCKS__DO'))
338336
.setAlign(Blockly.ALIGN_CENTRE);
@@ -341,4 +339,3 @@ Blockly.Blocks['sphero_sprk_plus_position_change'] = {
341339
this.setTooltip(i18t('Detect position change.'));
342340
},
343341
};
344-

0 commit comments

Comments
 (0)