Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/blocks/mrc_get_python_enum_value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ const GET_PYTHON_ENUM_VALUE = {
this.setTooltip(() => {
const enumClassName = this.getFieldValue(FIELD_ENUM_CLASS_NAME);
const enumValue = this.getFieldValue(FIELD_ENUM_VALUE);
let tooltip = 'Gets the enum value ' + enumClassName + '.' + enumValue + '.';
let tooltip = Blockly.Msg['GET_ENUM_VALUE_TOOLTIP']
.replace('%1', enumClassName)
.replace('%2', enumValue);
const enumTooltip = PythonEnumTooltips[enumClassName]
if (enumTooltip) {
if (typeof enumTooltip === 'string') {
Expand Down
18 changes: 12 additions & 6 deletions src/blocks/mrc_get_python_variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const GET_PYTHON_VARIABLE = {
*/
init: function(this: GetPythonVariableBlock): void {
this.appendDummyInput('VAR')
.appendField('get')
.appendField(Blockly.Msg['GET'])
.appendField(createFieldNonEditableText(''), FIELD_MODULE_OR_CLASS_NAME)
.appendField('.');
this.setStyle(MRC_STYLE_VARIABLES);
Expand All @@ -142,21 +142,27 @@ const GET_PYTHON_VARIABLE = {
switch (this.mrcVarKind) {
case VariableKind.MODULE: {
const moduleName = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Gets the variable ' + moduleName + '.' + varName + '.';
tooltip = Blockly.Msg['GET_MODULE_VARIABLE_TOOLTIP']
.replace('%1', moduleName)
.replace('%2', varName);
break;
}
case VariableKind.CLASS: {
const className = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Gets the variable ' + className + '.' + varName + '.';
tooltip = Blockly.Msg['GET_CLASS_VARIABLE_TOOLTIP']
.replace('%1', className)
.replace('%2', varName);
break;
}
case VariableKind.INSTANCE: {
const className = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Gets the variable ' + varName + ' for the given ' + className + ' object.';
tooltip = Blockly.Msg['GET_INSTANCE_VARIABLE_TOOLTIP']
.replace('%1', varName)
.replace('%2', className);
break;
}
default:
throw new Error('mrcVarKind must be "module", "class", or "instance".')
throw new Error(Blockly.Msg['VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE']);
}
const varTooltips = PythonVariableGetterTooltips[this.mrcKey];
if (varTooltips) {
Expand Down Expand Up @@ -286,7 +292,7 @@ export const pythonFromBlock = function(
return [code, Order.MEMBER];
}
default:
throw new Error('mrcVarKind must be "module", "class", or "instance".')
throw new Error(Blockly.Msg['VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE']);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/blocks/mrc_mechanism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const MECHANISM = {
nameField.setValidator(this.mrcNameFieldValidator.bind(this, nameField));
this.appendDummyInput()
.appendField(nameField, FIELD_NAME)
.appendField(Blockly.Msg.OF_TYPE)
.appendField(Blockly.Msg['OF_TYPE'])
.appendField(createFieldNonEditableText(''), FIELD_TYPE);
this.setPreviousStatement(true, OUTPUT_NAME);
this.setNextStatement(true, OUTPUT_NAME);
Expand Down Expand Up @@ -240,7 +240,7 @@ const MECHANISM = {
this.updateBlock_();
} else {
// Did not find the mechanism.
warnings.push('This block refers to a mechanism that no longer exists.');
warnings.push(Blockly.Msg['MECHANISM_NOT_FOUND_WARNING']);
}
}

Expand Down
20 changes: 13 additions & 7 deletions src/blocks/mrc_set_python_variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const SET_PYTHON_VARIABLE = {
*/
init: function(this: SetPythonVariableBlock): void {
this.appendValueInput('VALUE')
.appendField('set')
.appendField(Blockly.Msg['SET'])
.appendField(createFieldNonEditableText(''), FIELD_MODULE_OR_CLASS_NAME)
.appendField('.');
this.setStyle(MRC_STYLE_VARIABLES);
Expand All @@ -133,21 +133,27 @@ const SET_PYTHON_VARIABLE = {
switch (this.mrcVarKind) {
case VariableKind.MODULE: {
const moduleName = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Sets the variable ' + moduleName + '.' + varName + '.';
tooltip = Blockly.Msg['SET_MODULE_VARIABLE_TOOLTIP']
.replace('%1', moduleName)
.replace('%2', varName);
break;
}
case VariableKind.CLASS: {
const className = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Sets the variable ' + className + '.' + varName + '.';
tooltip = Blockly.Msg['SET_CLASS_VARIABLE_TOOLTIP']
.replace('%1', className)
.replace('%2', varName);
break;
}
case VariableKind.INSTANCE: {
const className = this.getFieldValue(FIELD_MODULE_OR_CLASS_NAME);
tooltip = 'Sets the variable ' + varName + ' for the given ' + className + ' object.';
tooltip = Blockly.Msg['SET_INSTANCE_VARIABLE_TOOLTIP']
.replace('%1', varName)
.replace('%2', className);
break;
}
default:
throw new Error('mrcVarKind must be "module", "class", or "instance".')
throw new Error(Blockly.Msg['VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE']);
}
const varTooltips = PythonVariableSetterTooltips[this.mrcKey];
if (varTooltips) {
Expand Down Expand Up @@ -226,7 +232,7 @@ const SET_PYTHON_VARIABLE = {
} else {
input.appendField(createFieldNonEditableText(''), FIELD_VARIABLE_NAME);
}
input.appendField('to');
input.appendField(Blockly.Msg['TO']);
if (this.mrcVarType) {
input.setCheck(getAllowedTypesForSetCheck(this.mrcVarType));
}
Expand Down Expand Up @@ -279,7 +285,7 @@ export const pythonFromBlock = function(
return code;
}
default:
throw new Error('mrcVarKind must be "module", "class", or "instance".')
throw new Error(Blockly.Msg['VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE']);
}
};

Expand Down
12 changes: 12 additions & 0 deletions src/blocks/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export function customTokens(t: (key: string) => string): typeof Blockly.Msg {
ROBOT_LOWER_CASE: t('BLOCKLY.ROBOT_LOWER_CASE'),
CREATE: t('BLOCKLY.CREATE'),
FIRE: t('BLOCKLY.FIRE'),
GET: t('BLOCKLY.GET'),
GET_MODULE_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.GET_MODULE_VARIABLE'),
GET_CLASS_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.GET_CLASS_VARIABLE'),
GET_INSTANCE_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.GET_INSTANCE_VARIABLE'),
GET_ENUM_VALUE_TOOLTIP: t('BLOCKLY.TOOLTIP.GET_ENUM_VALUE'),
SET: t('BLOCKLY.SET'),
TO: t('BLOCKLY.TO'),
SET_MODULE_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.SET_MODULE_VARIABLE'),
SET_CLASS_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.SET_CLASS_VARIABLE'),
SET_INSTANCE_VARIABLE_TOOLTIP: t('BLOCKLY.TOOLTIP.SET_INSTANCE_VARIABLE'),
VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE: t('BLOCKLY.ERROR.VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE'),
MECHANISM_NOT_FOUND_WARNING: t('BLOCKLY.WARNING.MECHANISM_NOT_FOUND'),
WARNING_CALL_COMPONENT_INSTANCE_METHOD_PRIVATE_COMPONENT: t('BLOCKLY.WARNING.CALL_COMPONENT_INSTANCE_METHOD_PRIVATE_COMPONENT'),
WARNING_CALL_COMPONENT_INSTANCE_METHOD_MISSING_COMPONENT: t('BLOCKLY.WARNING.CALL_COMPONENT_INSTANCE_METHOD_MISSING_COMPONENT'),
WARNING_CALL_MECHANISM_COMPONENT_INSTANCE_METHOD_MISSING_MECHANISM: t('BLOCKLY.WARNING.CALL_MECHANISM_COMPONENT_INSTANCE_METHOD_MISSING_MECHANISM'),
Expand Down
18 changes: 16 additions & 2 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
"ROBOT": "robot",
"CREATE": "create",
"FIRE": "fire",
"GET": "get",
"SET": "set",
"TO": "to",
"TOOLTIP":{
"EVALUATE_BUT_IGNORE_RESULT": "Executes the connected block and ignores the result. Allows you to call a function and ignore the return value.",
"NONE": "Returns None.",
Expand All @@ -115,7 +118,14 @@
"CALL_MECHANISM_COMPONENT_INSTANCE_METHOD": "Calls the instance method {{className}}.{{functionName}} on the component named {{componentName}} in the mechanism named {{mechanismName}}.",
"CALL_COMPONENT_INSTANCE_METHOD": "Calls the instance method {{className}}.{{functionName}} on the component named {{componentName}}.",
"CALL_ROBOT_INSTANCE_METHOD": "Calls the robot method {{functionName}}.",
"CALL_MECHANISM_INSTANCE_METHOD": "Calls the instance method {{className}}.{{functionName}} on the mechanism named {{mechanismName}}."
"CALL_MECHANISM_INSTANCE_METHOD": "Calls the instance method {{className}}.{{functionName}} on the mechanism named {{mechanismName}}.",
"GET_MODULE_VARIABLE": "Gets the variable %1.%2.",
"GET_CLASS_VARIABLE": "Gets the variable %1.%2.",
"GET_INSTANCE_VARIABLE": "Gets the variable %1 for the given %2 object.",
"GET_ENUM_VALUE": "Gets the enum value %1.%2.",
"SET_MODULE_VARIABLE": "Sets the variable %1.%2.",
"SET_CLASS_VARIABLE": "Sets the variable %1.%2.",
"SET_INSTANCE_VARIABLE": "Sets the variable %1 for the given %2 object."
},
"CATEGORY":{
"LISTS": "Lists",
Expand Down Expand Up @@ -145,7 +155,11 @@
"CALL_MECHANISM_INSTANCE_METHOD_INSIDE_MECHANISM": "This block is not allowed to be used inside a mechanism.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_METHOD": "This block calls a method that no longer exists in the mechanism.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_MECHANISM": "This block calls a method in a mechanism that no longer exists.",
"EVENT_NOT_IN_HOLDER": "This block can only go in the events section of the robot or mechanism."
"EVENT_NOT_IN_HOLDER": "This block can only go in the events section of the robot or mechanism.",
"MECHANISM_NOT_FOUND": "This block refers to a mechanism that no longer exists."
},
"ERROR":{
"VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE": "mrcVarKind must be \"module\", \"class\", or \"instance\"."
}
}
}
18 changes: 16 additions & 2 deletions src/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
"ROBOT": "robot",
"CREATE": "crear",
"FIRE": "disparar",
"GET": "obtener",
"SET": "establecer",
"TO": "a",
"TOOLTIP": {
"EVALUATE_BUT_IGNORE_RESULT": "Ejecuta el bloque conectado e ignora el resultado. Te permite llamar una función e ignorar el valor de retorno.",
"NONE": "No devuelve ninguno.",
Expand All @@ -116,7 +119,14 @@
"CALL_MECHANISM_COMPONENT_INSTANCE_METHOD": "Llama al método de instancia {{className}}.{{functionName}} en el componente llamado {{componentName}} en el mecanismo llamado {{mechanismName}}.",
"CALL_COMPONENT_INSTANCE_METHOD": "Llama al método de instancia {{className}}.{{functionName}} en el componente llamado {{componentName}}.",
"CALL_ROBOT_INSTANCE_METHOD": "Llama al método robot {{functionName}}.",
"CALL_MECHANISM_INSTANCE_METHOD": "Llama al método de instancia {{className}}.{{functionName}} en el mecanismo llamado {{mechanismName}}."
"CALL_MECHANISM_INSTANCE_METHOD": "Llama al método de instancia {{className}}.{{functionName}} en el mecanismo llamado {{mechanismName}}.",
"GET_MODULE_VARIABLE": "Obtiene la variable %1.%2.",
"GET_CLASS_VARIABLE": "Obtiene la variable %1.%2.",
"GET_INSTANCE_VARIABLE": "Obtiene la variable %1 para el objeto %2 dado.",
"GET_ENUM_VALUE": "Obtiene el valor de enumeración %1.%2.",
"SET_MODULE_VARIABLE": "Establece la variable %1.%2.",
"SET_CLASS_VARIABLE": "Establece la variable %1.%2.",
"SET_INSTANCE_VARIABLE": "Establece la variable %1 para el objeto %2 dado."
},
"CATEGORY": {
"LISTS": "Listas",
Expand Down Expand Up @@ -146,7 +156,11 @@
"CALL_MECHANISM_INSTANCE_METHOD_INSIDE_MECHANISM": "No se permite utilizar este bloque dentro de un mecanismo.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_METHOD": "Este bloque llama a un método que ya no existe en el mecanismo.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_MECHANISM": "Este bloque llama a un método en un mecanismo que ya no existe.",
"EVENT_NOT_IN_HOLDER": "Este bloque solo puede ir en la sección de eventos del robot o mecanismo."
"EVENT_NOT_IN_HOLDER": "Este bloque solo puede ir en la sección de eventos del robot o mecanismo.",
"MECHANISM_NOT_FOUND": "Este bloque se refiere a un mecanismo que ya no existe."
},
"ERROR":{
"VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE": "mrcVarKind debe ser \"module\", \"class\" o \"instance\"."
}
}
}
18 changes: 16 additions & 2 deletions src/i18n/locales/he/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
"ROBOT": "רובוט",
"CREATE": "צור",
"FIRE": "הפעל",
"GET": "קבל",
"SET": "הגדר",
"TO": "ל",
"TOOLTIP": {
"EVALUATE_BUT_IGNORE_RESULT": "מבצע את הבלוק המחובר ומתעלם מהתוצאה. מאפשר לקרוא לפונקציה מבלי להשתמש בערך שהיא מחזירה.",
"NONE": "מחזיר כלום.",
Expand All @@ -115,7 +118,14 @@
"CALL_MECHANISM_COMPONENT_INSTANCE_METHOD": "קורא למתודה {{className}}.{{functionName}} על הרכיב {{componentName}} במנגנון {{mechanismName}}.",
"CALL_COMPONENT_INSTANCE_METHOD": "קורא למתודה {{className}}.{{functionName}} על הרכיב {{componentName}}.",
"CALL_ROBOT_INSTANCE_METHOD": "קורא למתודת הרובוט {{functionName}}.",
"CALL_MECHANISM_INSTANCE_METHOD": "קורא למתודה {{className}}.{{functionName}} במנגנון {{mechanismName}}."
"CALL_MECHANISM_INSTANCE_METHOD": "קורא למתודה {{className}}.{{functionName}} במנגנון {{mechanismName}}.",
"GET_MODULE_VARIABLE": "מקבל את המשתנה %1.%2.",
"GET_CLASS_VARIABLE": "מקבל את המשתנה %1.%2.",
"GET_INSTANCE_VARIABLE": "מקבל את המשתנה %1 עבור אובייקט %2 נתון.",
"GET_ENUM_VALUE": "מקבל את ערך ההספירה %1.%2.",
"SET_MODULE_VARIABLE": "מגדיר את המשתנה %1.%2.",
"SET_CLASS_VARIABLE": "מגדיר את המשתנה %1.%2.",
"SET_INSTANCE_VARIABLE": "מגדיר את המשתנה %1 עבור אובייקט %2 נתון."
},
"CATEGORY": {
"LISTS": "רשימות",
Expand Down Expand Up @@ -145,7 +155,11 @@
"CALL_MECHANISM_INSTANCE_METHOD_INSIDE_MECHANISM": "בלוק זה אינו מורשה לשימוש בתוך מנגנון.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_METHOD": "בלוק זה קורא למתודה שכבר לא קיימת במנגנון.",
"CALL_MECHANISM_INSTANCE_METHOD_MISSING_MECHANISM": "בלוק זה קורא למתודה במנגנון שכבר לא קיים.",
"EVENT_NOT_IN_HOLDER": "בלוק זה יכול להיכנס רק לאזור האירועים של הרובוט או המנגנון."
"EVENT_NOT_IN_HOLDER": "בלוק זה יכול להיכנס רק לאזור האירועים של הרובוט או המנגנון.",
"MECHANISM_NOT_FOUND": "בלוק זה מתייחס למנגנון שכבר לא קיים."
},
"ERROR": {
"VAR_KIND_MUST_BE_MODULE_CLASS_OR_INSTANCE": "mrcVarKind חייב להיות \"module\", \"class\" או \"instance\"."
}
}
}