Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internacionalizacion de procedimientos #907

Merged
merged 10 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 8 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: 1 addition & 3 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
<script src="assets/client.min.js"></script>
<script src="assets/uuidv4.min.js"></script>
<script src="assets/unzipit.min.js"></script>
<script>
initProcedsBlockly();
asanzo marked this conversation as resolved.
Show resolved Hide resolved
</script>

{{content-for "body-footer"}}
</body>
</html>
44 changes: 40 additions & 4 deletions app/services/blocks-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,41 @@ export default Service.extend({
});
},

defineProcedureTranslations(){
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE = this.tString("procedures.name")
Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE = this.tString("procedures.definition")
Blockly.Msg.PROCEDURES_BEFORE_PARAMS = this.tString("procedures.paramWith")
Blockly.Msg.PROCEDURES_PARAMETER = this.tString("procedures.paramName")
Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS = this.tString("procedures.paramWith")
Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP = this.tString("procedures.create")
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = this.tString("procedures.comment")
Blockly.Msg.PROCEDURES_DEFNORETURN_NOPARAMS = this.tString("procedures.noParams")
Blockly.Msg.PROCEDURES_ADD_PARAMETER = this.tString("procedures.addParam")
Blockly.Msg.PROCEDURES_ADD_PARAMETER_PROMPT = this.tString("procedures.addParamPrompt")
Blockly.Msg.PROCEDURES_REMOVE_PARAMETER = this.tString("procedures.removeParam")

// ProcedsBlockly.init() needs all procedure blocks to work, so we need to put them back
// After calling init(), we disable unwanted toolbox blocks again
this._enableUnwantedProcedureBlocks()
ProcedsBlockly.init()
asanzo marked this conversation as resolved.
Show resolved Hide resolved
this._disableUnwantedProcedureBlocks()
},

_disableUnwantedProcedureBlocks() {
['procedures_defreturn','procedures_ifreturn'].forEach(blockType => {
if (Blockly.Blocks[blockType]) {
Blockly['bkp_'+blockType] = Blockly.Blocks[blockType]
delete Blockly.Blocks[blockType]
}
})
},

_enableUnwantedProcedureBlocks() {
['procedures_defreturn','procedures_ifreturn'].forEach(blockType => {
if (Blockly['bkp_'+blockType]) Blockly.Blocks[blockType] = Blockly['bkp_'+blockType]
})
},

_definirColores() {
// Pisar las globales de Blockly es necesario pues usamos algunos bloques de Blockly como aliases.
Blockly.Blocks.math.HUE = 94; // En PB 1.1.2 era '#48930e'
Expand Down Expand Up @@ -1360,16 +1395,17 @@ export default Service.extend({
}
};

Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE = "Definir";
// Blockly dynamically loads stuff in procedures category that we don't want, so we take them out
this._disableUnwantedProcedureBlocks()

this.defineProcedureTranslations()

let init_base_procedimiento = Blockly.Blocks.procedures_defnoreturn.init;

Blockly.Blocks.procedures_defnoreturn.init = function () {
init_base_procedimiento.call(this);
};

delete Blockly.Blocks.procedures_defreturn;
delete Blockly.Blocks.procedures_ifreturn;

},

_generarLenguaje() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"clientjs": "^0.1.11",
"creador-de-desafios-pilasbloques": "^1.0.1",
"pilas-bloques-exercises": "1.2.3",
"proceds-blockly": "^1.0.1",
"proceds-blockly": "^1.1.0",
"unzipit": "^1.3.5",
"survey-knockout": "^1.8.0",
"uuid": "^8.3.0",
Expand Down
1 change: 0 additions & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<script src="assets/unzipit.min.js"></script>
<script src="assets/pilasbloques.js"></script>
<script src="assets/tests.js"></script>
<script>initProcedsBlockly();</script>

{{content-for "body-footer"}}
{{content-for "test-body-footer"}}
Expand Down
13 changes: 12 additions & 1 deletion translations/blocks/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,15 @@ categories:
sensors: "Sensors"
operators: "Operators"
myFunctions: "My functions"
uncategorized: "Uncategorized"
uncategorized: "Uncategorized"
procedures:
definition: "Define"
name: "Do something"
paramWith: "with"
paramName: "parameter"
create: "Create a procedure."
removeParam: "Remove parameter"
comment: "Describe the procedure..."
noParams: ""
addParam: "Add parameter"
addParamPrompt: "Enter the parameter's name"
11 changes: 11 additions & 0 deletions translations/blocks/es-ar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,14 @@ categories:
operators: "Operadores"
myFunctions: "Mis funciones"
uncategorized: "SIN CATEGORÍA"
procedures:
definition: "Definir"
name: "Hacer algo"
paramWith: "con"
paramName: "parámetro"
create: "Crea un procedimiento."
removeParam: "Quitar parámetro"
comment: "Describe el procedimiento..."
noParams: ""
addParam: "Agregar parámetro"
addParamPrompt: "Ingresa el nombre del parámetro"