Skip to content

Commit

Permalink
Merge pull request #907 from Program-AR/procedures-internationalization
Browse files Browse the repository at this point in the history
Internacionalizacion de procedimientos
  • Loading branch information
asanzo authored Mar 25, 2022
2 parents efa5460 + 829dd7a commit b9b7d18
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Blob",
"ClientJS",
"uuidv4",
"unzipit"
"unzipit",
"ProcedsBlockly"
],
"esversion": 9,
"asi": true,
Expand Down
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();
</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()
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 @@ -59,8 +59,8 @@
"creador-de-desafios-pilasbloques": "^1.0.1",
"pilas-bloques-ember-intl": "^1.1.1",
"pilas-bloques-exercises": "1.2.3",
"proceds-blockly": "^1.1.0",
"pilasweb": "^0.5.0",
"proceds-blockly": "^1.0.1",
"unzipit": "^1.3.5",
"survey-knockout": "^1.8.0",
"uuid": "^8.3.0"
Expand Down
3 changes: 2 additions & 1 deletion tests/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"Blob",
"localStorage",
"ClientJS",
"uuidv4"
"uuidv4",
"ProcedsBlockly"
],
"esversion": 9,
"asi": true,
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"

0 comments on commit b9b7d18

Please sign in to comment.