Skip to content

Commit b641ef4

Browse files
committed
Move some items from our blocks into being translated
1 parent 5ee4bec commit b641ef4

File tree

8 files changed

+60
-21
lines changed

8 files changed

+60
-21
lines changed

public/locales/en/translation.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@
2121
"search": "Search..."
2222
},
2323
"BLOCKLY":{
24-
"OF_TYPE": "of type"
24+
"OF_TYPE": "of type",
25+
"WITH": "with",
26+
"WHEN": "when",
27+
"PARAMETER": "parameter",
28+
"PARAMETERS_CAN_ONLY_GO_IN_THEIR_METHODS_BLOCK": "Parameters can only go in their method's block",
29+
"MECHANISMS": "Mechanisms",
30+
"COMPONENTS": "Components",
31+
"EVENTS": "Events",
32+
"EVALUATE_BUT_IGNORE_RESULT": "evaluate but ignore result",
33+
"TYPE": "Type",
34+
"ENABLED": "Enabled",
35+
"DISPLAY_NAME": "Display Name",
36+
"DISPLAY_GROUP": "Display Group",
37+
"TOOLTIP":{
38+
"EVALUATE_BUT_IGNORE_RESULT": "Executes the connected block and ignores the result. Allows you to call a function and ignore the return value.",
39+
"OPMODE_TYPE": "What sort of OpMode this is",
40+
"OPMODE_ENABLED": "Whether the OpMode is shown on Driver Station",
41+
"OPMODE_NAME": "The name shown on the Driver Station. If blank will use the class name.",
42+
"OPMODE_GROUP": "An optional group to group OpModes on Driver Station"
43+
}
2544
}
2645
}

src/blocks/mrc_event_handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ const EVENT_HANDLER = {
6565
*/
6666
init(this: EventHandlerBlock): void {
6767
this.appendDummyInput('TITLE')
68-
.appendField('When')
68+
.appendField(Blockly.Msg.WHEN)
6969
.appendField(createFieldNonEditableText('sender'), 'SENDER')
7070
.appendField(createFieldNonEditableText('eventName'), 'EVENT_NAME');
7171
this.appendDummyInput('PARAMS')
72-
.appendField('with');
72+
.appendField(Blockly.Msg.WITH);
7373
this.setOutput(false);
7474
this.setStyle(MRC_STYLE_EVENT_HANDLER);
7575
this.appendStatementInput('STACK').appendField('');

src/blocks/mrc_get_parameter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const GET_PARAMETER_BLOCK = {
4949
init: function(this: GetParameterBlock): void {
5050
this.setStyle(MRC_STYLE_VARIABLES);
5151
this.appendDummyInput()
52-
.appendField('parameter')
52+
.appendField(Blockly.Msg.PARAMETER)
5353
.appendField(createFieldNonEditableText('parameter'), 'PARAMETER_NAME');
5454

5555
this.setOutput(true, this.parameterType);
@@ -89,7 +89,7 @@ const GET_PARAMETER_BLOCK = {
8989
}
9090
// If we end up here it shouldn't be allowed
9191
block.unplug(true);
92-
blockBlock.setWarningText('Parameters can only go in their method\'s block.');
92+
blockBlock.setWarningText(Blockly.Msg.PARAMETERS_CAN_ONLY_GO_IN_THEIR_METHODS_BLOCK);
9393
}
9494
},
9595
};

src/blocks/mrc_mechanism.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const MECHANISM = {
5555
this.setStyle(MRC_STYLE_MECHANISMS);
5656
this.appendDummyInput()
5757
.appendField(new Blockly.FieldTextInput('my_mech'), 'NAME')
58-
.appendField('of type')
58+
.appendField(Blockly.Msg.OF_TYPE)
5959
.appendField(createFieldNonEditableText(''), 'TYPE');
6060
this.setPreviousStatement(true, OUTPUT_NAME);
6161
this.setNextStatement(true, OUTPUT_NAME);

src/blocks/mrc_mechanism_component_holder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ const MECHANISM_COMPONENT_HOLDER = {
7272
*/
7373
init: function (this: MechanismComponentHolderBlock): void {
7474
this.setInputsInline(false);
75-
this.appendStatementInput('MECHANISMS').setCheck(MECHANISM_OUTPUT).appendField('Mechanisms');
76-
this.appendStatementInput('COMPONENTS').setCheck(COMPONENT_OUTPUT).appendField('Components');
77-
this.appendStatementInput('EVENTS').setCheck(EVENT_OUTPUT).appendField('Events');
75+
this.appendStatementInput('MECHANISMS').setCheck(MECHANISM_OUTPUT).appendField(Blockly.Msg.MECHANISMS);
76+
this.appendStatementInput('COMPONENTS').setCheck(COMPONENT_OUTPUT).appendField(Blockly.Msg.COMPONENTS);
77+
this.appendStatementInput('EVENTS').setCheck(EVENT_OUTPUT).appendField(Blockly.Msg.EVENTS);
7878

7979

8080
this.setOutput(false);

src/blocks/mrc_misc_evaluate_but_ignore_result.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ export const setup = function() {
3131
Blockly.Blocks[BLOCK_NAME] = {
3232
init: function() {
3333
this.appendValueInput('VALUE')
34-
.appendField('evaluate but ignore result')
34+
.appendField(Blockly.Msg.EVALUATE_BUT_IGNORE_RESULT)
3535
.setAlign(Blockly.inputs.Align.RIGHT);
3636
this.setPreviousStatement(true);
3737
this.setNextStatement(true);
3838
this.setStyle(MRC_STYLE_MISC);
3939
this.setTooltip(
40-
'Executes the connected block and ignores the result. ' +
41-
'Allows you to call a function and ignore the return value.');
40+
Blockly.Msg.EVALUATE_BUT_IGNORE_RESULT_TOOLTIP);
4241
},
4342
};
4443
};

src/blocks/mrc_opmode_details.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ const OPMODE_DETAILS = {
6161
init: function (this: OpmodeDetailsBlock): void {
6262
this.setStyle(MRC_STYLE_CLASS_BLOCKS);
6363
this.appendDummyInput()
64-
.appendField('Type')
65-
.appendField(createFieldDropdown(['Auto', 'Teleop', 'Test']), 'TYPE')
64+
.appendField(Blockly.Msg.TYPE)
65+
.appendField(createFieldDropdown([Blockly.Msg.AUTO, Blockly.Msg.TELEOP, Blockly.Msg.TEST]), 'TYPE')
6666
.appendField(' ')
67-
.appendField('Enabled')
67+
.appendField(Blockly.Msg.ENABLED)
6868
.appendField(new Blockly.FieldCheckbox(true), 'ENABLED');
6969

7070
this.appendDummyInput()
71-
.appendField('Display Name')
71+
.appendField(Blockly.Msg.DISPLAY_NAME)
7272
.appendField(new Blockly.FieldTextInput(''), 'NAME')
7373
this.appendDummyInput()
74-
.appendField('Display Group')
74+
.appendField(Blockly.Msg.DISPLAY_GROUP)
7575
.appendField(new Blockly.FieldTextInput(''), 'GROUP');
7676

77-
this.getField('TYPE')?.setTooltip('What sort of OpMode this is');
78-
this.getField('ENABLED')?.setTooltip('Whether the OpMode is shown on Driver Station');
79-
this.getField('NAME')?.setTooltip('The name shown on the Driver Station. If blank will use the class name.');
80-
this.getField('GROUP')?.setTooltip('An optional group to group OpModes on Driver Station');
77+
this.getField('TYPE')?.setTooltip(Blockly.Msg.OPMODE_TYPE_TOOLTIP);
78+
this.getField('ENABLED')?.setTooltip(Blockly.Msg.OPMODE_ENABLED_TOOLTIP);
79+
this.getField('NAME')?.setTooltip(Blockly.Msg.OPMODE_NAME_TOOLTIP);
80+
this.getField('GROUP')?.setTooltip(Blockly.Msg.OPMODE_GROUP_TOOLTIP);
8181
},
8282
}
8383

src/blocks/tokens.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
import * as Blockly from 'blockly/core';
2+
import { M } from 'vitest/dist/chunks/reporters.d.BFLkQcL6.js';
23

34
export const customTokens = (t: (key: string) => string): typeof Blockly.Msg => {
45
return {
56
ADD_COMMENT: t('BLOCKLY.ADD_COMMENT'),
67
REMOVE_COMMENT: t('BLOCKLY.REMOVE_COMMENT'),
78
DUPLICATE_COMMENT: t('BLOCKLY.DUPLICATE_COMMENT'),
89
OF_TYPE: t('BLOCKLY.OF_TYPE'),
10+
WITH: t('BLOCKLY.WITH'),
11+
WHEN: t('BLOCKLY.WHEN'),
12+
PARAMETER: t('BLOCKLY.PARAMETER'),
13+
PARAMETERS_CAN_ONLY_GO_IN_THEIR_METHODS_BLOCK: t('BLOCKLY.PARAMETERS_CAN_ONLY_GO_IN_THEIR_METHODS_BLOCK'),
14+
MECHANISMS: t('BLOCKLY.MECHANISMS'),
15+
COMPONENTS: t('BLOCKLY.COMPONENTS'),
16+
EVENTS: t('BLOCKLY.EVENTS'),
17+
EVALUATE_BUT_IGNORE_RESULT: t('BLOCKLY.EVALUATE_BUT_IGNORE_RESULT'),
18+
EVALUATE_BUT_IGNORE_RESULT_TOOLTIP: t('BLOCKLY.EVALUATE_BUT_IGNORE_RESULT_TOOLTIP'),
19+
AUTO: t('BLOCKLY.AUTO'),
20+
TELEOP: t('BLOCKLY.TELEOP'),
21+
TEST: t('BLOCKLY.TEST'),
22+
TYPE: t('BLOCKLY.TYPE'),
23+
ENABLED: t('BLOCKLY.ENABLED'),
24+
DISPLAY_NAME: t('BLOCKLY.DISPLAY_NAME'),
25+
DISPLAY_GROUP: t('BLOCKLY.DISPLAY_GROUP'),
26+
OPMODE_TYPE_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_TYPE_TOOLTIP'),
27+
OPMODE_ENABLED_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_ENABLED_TOOLTIP'),
28+
OPMODE_NAME_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_NAME_TOOLTIP'),
29+
OPMODE_GROUP_TOOLTIP: t('BLOCKLY.TOOLTIP.OPMODE_GROUP_TOOLTIP'),
930
};
1031
};

0 commit comments

Comments
 (0)