Code Monkey home page Code Monkey logo

Comments (5)

carlosperate avatar carlosperate commented on June 5, 2024

In case anybody looking at this issue is wondering, the original question is asking about Ardublockly translations, if its possible and how to do it, in particular a spanish translation.

At the moment the text in the Arduino specific blocks are not included in the language file for Blockly, but all the original blockly blocks have translations.

Basically what first needs to happen for it to be fully translated is to move all literal strings from the files in the blockly/blocks/arduino folder into the blockly/msg/messages.js file.

So, for example this io_digitalwrite block needs to be changed from:

    this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
    this.setColour(Blockly.Blocks.Arduino.io.HUE);
    this.appendDummyInput('')
        .appendField('set digital pin#')
        .appendField(new Blockly.FieldDropdown(
            Blockly.Arduino.Boards.selected.digitalPins), 'PIN');
    this.appendValueInput('STATE', Blockly.StaticTyping.BlocklyType.BOOLEAN)
        .appendField('to')
        .setCheck(Blockly.StaticTyping.BlocklyType.BOOLEAN);
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip('Write digital value to a specific Port.');

to:

    this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
    this.setColour(Blockly.Blocks.Arduino.io.HUE);
    this.appendDummyInput('')
        .appendField(Blockly.Msg.IO_DIGITALWRITE_TITLE)
        .appendField(new Blockly.FieldDropdown(
            Blockly.Arduino.Boards.selected.digitalPins), 'PIN');
    this.appendValueInput('STATE', Blockly.StaticTyping.BlocklyType.BOOLEAN)
        .appendField(Blockly.Msg.IO_DIGITALWRITE_TITLE_2)
        .setCheck(Blockly.StaticTyping.BlocklyType.BOOLEAN);
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip(Blockly.Msg.IO_DIGITALWRITE_TITLE_TOOLTIP);

(in this case, there are two strings inside the block, IO_DIGITALWRITE_TITLE and IO_DIGITALWRITE_TITLE_2, this is not a good practice for translations, but once we've got the majority of the strings moved I can look into changing it to a better way)

So, the strings are then moved into the blockly/msg/messages.js file:

// Meaningful description
Blockly.Msg.IO_DIGITALWRITE_TITLE_TITLE = 'set digital pin#';
Blockly.Msg.IO_DIGITALWRITE_TITLE_TITLE_2 = 'to';
Blockly.Msg.IO_DIGITALWRITE_TITLE_TOOLTIP = 'Write digital value to a specific Port';

Once that is done, the language files can be automatically generated to include all the new strings, and then it's a matter to edit the translation in the respective file, like this file for the spanish language.


Hola Jose,

Por el momento the texto en los bloques especificos de Arduino no estan incluidos en la traduccion general de Blockly, pero todos los otros bloques tienen traducciones.

Principalmente lo que tiene que pasar primero para poder traducirlo es mover todos los strings de texto de los archivos incluidos en la carpeta blockly/blocks/arduino a dentro del archivo blockly/msg/messages.js.

Por ejemplo, para este bloque io_digitalwrite necesitariamos cambiar el siguiente codigo:

    this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
    this.setColour(Blockly.Blocks.Arduino.io.HUE);
    this.appendDummyInput('')
        .appendField('set digital pin#')
        .appendField(new Blockly.FieldDropdown(
            Blockly.Arduino.Boards.selected.digitalPins), 'PIN');
    this.appendValueInput('STATE', Blockly.StaticTyping.BlocklyType.BOOLEAN)
        .appendField('to')
        .setCheck(Blockly.StaticTyping.BlocklyType.BOOLEAN);
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip('Write digital value to a specific Port.');

al siguiente:

    this.setHelpUrl('http://arduino.cc/en/Reference/DigitalWrite');
    this.setColour(Blockly.Blocks.Arduino.io.HUE);
    this.appendDummyInput('')
        .appendField(Blockly.Msg.IO_DIGITALWRITE_TITLE)
        .appendField(new Blockly.FieldDropdown(
            Blockly.Arduino.Boards.selected.digitalPins), 'PIN');
    this.appendValueInput('STATE', Blockly.StaticTyping.BlocklyType.BOOLEAN)
        .appendField(Blockly.Msg.IO_DIGITALWRITE_TITLE_2)
        .setCheck(Blockly.StaticTyping.BlocklyType.BOOLEAN);
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip(Blockly.Msg.IO_DIGITALWRITE_TITLE_TOOLTIP);

(en este caso especifico, hay dos strings dentro del bloque, IO_DIGITALWRITE_TITLE y IO_DIGITALWRITE_TITLE_2, lo cual no es una buena practica para las traducciones, pero tan pronto como el texto se haya movido al archivo adecuado me puedo encargar de mejoralo al formato correcto)

Finalmente, esas strings se tienen que mover al archivo blockly/msg/messages.js:

// Meaningful description
Blockly.Msg.IO_DIGITALWRITE_TITLE_TITLE = 'set digital pin#';
Blockly.Msg.IO_DIGITALWRITE_TITLE_TITLE_2 = 'to';
Blockly.Msg.IO_DIGITALWRITE_TITLE_TOOLTIP = 'Write digital value to a specific Port';

Una vez esto este hecho, los archivos de lenguaje pueden ser automaticamente generados para incluir las nuevas strings. Despues simplemente es cuestion de editar la traduccion en los respectivos archivos, en este caso seria este archivo para la lengua española.

from ardublockly.

SebCanet avatar SebCanet commented on June 5, 2024

Hell everybody,
thanks a lot for your work on Blockly. I tried to create a wiki about this particular point :
http://tic.technologiescollege.fr/wiki/doku.php/en/blockly_rduino/create_blocks

Tell me if it's undestandable. There's a lot of file ot change on BlocklyDuino about this point.

Thanks.

from ardublockly.

carlosperate avatar carlosperate commented on June 5, 2024

The first step for internationalisation has been implemented in commit c669586.

So far this will only trigger a language change in the core blockly blocks, a list of what has been done and is left has been added to the initial message on this issue (as it is the only way to trigger github task tracker).

from ardublockly.

isokar avatar isokar commented on June 5, 2024

Hi,
I was wondering where were the question of internationalisation? I propose my help for a french version of it.
and thanks again for the great tool

from ardublockly.

carlosperate avatar carlosperate commented on June 5, 2024

Hi @isokar, I am not quite sure I understand your question, could you rephrase it? Are you wondering how to change the language in the Ardublockly application?
We have a base for the french translation (as you can see in blockly/msg/js and blockly/msg/json/fr.json), but if there is anything missing or that might require some tweaking contributions are more than welcomed :)

from ardublockly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.