diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bbd333c..1d1768b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -48,4 +48,5 @@ jobs: with: artifacts: "build/scratch-arduino-app*.zip" allowUpdates: true + prerelease: ${{ contains(github.ref_name, 'rc') }} token: ${{ github.token }} diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js index c3085fd..f7b79ab 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_basics/index.js @@ -1,6 +1,7 @@ // const formatMessage = require('../../../../../../scratch-editor/node_modules/format-message'); const BlockType = require('../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/block-type'); const ArgumentType = require('../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type'); +const formatMessage = require('../../../../../../scratch-editor/node_modules/format-message'); const io = require('../socket.io.min.js'); /** @@ -34,14 +35,22 @@ class ArduinoBasics { ArduinoBasics.prototype.getInfo = function () { return { id: 'arduinobasics', - name: "Arduino Basics", + name: formatMessage({ + id: 'arduino.basics', + defaultMessage: 'Arduino Basics', + description: 'The name of the "Arduino Basics" extension' + }), menuIconURI: menuIconURI, blockIconURI: iconURI, blocks: [ { opcode: 'matrixDraw', blockType: BlockType.COMMAND, - text: 'draw [FRAME] on matrix', + text: formatMessage({ + id: 'arduino.drawMatrix', + defaultMessage: 'show [FRAME] on matrix', + description: 'Draw the given frame on the LED matrix' + }), func: 'matrixDraw', arguments: { FRAME: { diff --git a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js index adb39e0..f7300bb 100644 --- a/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js +++ b/scratch-arduino-extensions/packages/scratch-vm/src/extensions/arduino_modulino/index.js @@ -1,5 +1,7 @@ const BlockType = require('../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/block-type'); const ArgumentType = require('../../../../../../scratch-editor/packages/scratch-vm/src/extension-support/argument-type'); +const formatMessage = require('../../../../../../scratch-editor/node_modules/format-message'); + const io = require('../socket.io.min.js'); @@ -40,14 +42,22 @@ class ArduinoModulino { ArduinoModulino.prototype.getInfo = function () { return { id: 'arduinomodulino', - name: "Arduino Modulino", + name: formatMessage({ + id: 'arduino.modulino', + defaultMessage: 'Arduino Modulino', + description: 'The name of the "Arduino Modulino" extension' + }), menuIconURI: menuIconURI, blockIconURI: iconURI, blocks: [ { opcode: 'whenModulinoButtonsPressed', blockType: BlockType.HAT, - text: 'when modulino button [BTN] pressed', + text: formatMessage({ + id: 'arduino.modulino.whenPressed', + defaultMessage: 'when modulino button [BTN] pressed', + description: 'When the specified modulino button is pressed' + }), func: 'whenModulinoButtonsPressed', arguments: { BTN: { diff --git a/scratch-arduino-extensions/scratch-l10n/locales/editor-msgs.json b/scratch-arduino-extensions/scratch-l10n/locales/editor-msgs.json new file mode 100644 index 0000000..ac54247 --- /dev/null +++ b/scratch-arduino-extensions/scratch-l10n/locales/editor-msgs.json @@ -0,0 +1,9 @@ +{ + "it": { + "arduino.basics": "Arduino Base", + "arduino.drawMatrix": "mostra led [FRAME]", + + "arduino.modulino": "Arduino Modulino", + "arduino.modulino.whenPressed": "quando premi il bottone [BTN]" + } +} \ No newline at end of file diff --git a/scratch-arduino-extensions/scripts/patch-gui.js b/scratch-arduino-extensions/scripts/patch-gui.js index 6da7d94..444d6c5 100644 --- a/scratch-arduino-extensions/scripts/patch-gui.js +++ b/scratch-arduino-extensions/scripts/patch-gui.js @@ -46,8 +46,28 @@ extensions.forEach(extension => { fs.writeFileSync(scratchVmVirtualMachineFile, vmCode); process.stdout.write("done\n"); } else process.stdout.write("skip"); + }); +process.stdout.write("\nAdding translation: "); +const scratchl10nEditorMsgsFile = path.resolve(BaseDir,"../scratch-editor/node_modules/scratch-l10n/locales/editor-msgs.js"); +let fileContent = fs.readFileSync(scratchl10nEditorMsgsFile, "utf8"); +let match = fileContent.match(/export default (\{.*\});/s); +if (!match) { + throw new Error("Could not find object in file"); +} +let obj = eval("(" + match[1] + ")"); +fs.copyFileSync(scratchl10nEditorMsgsFile, `${scratchl10nEditorMsgsFile}.orig`); + +const patchedMessages = path.resolve(BaseDir,"./scratch-l10n/locales/editor-msgs.json"); +let messages = JSON.parse(fs.readFileSync(patchedMessages, "utf8")); +for (let lang in messages) { + process.stdout.write(`\n\t - ${lang}`); + obj[lang] = { ...obj[lang], ...messages[lang] }; +} +let updatedContent = "export default " + JSON.stringify(obj, null, 2) + ";"; +fs.writeFileSync(scratchl10nEditorMsgsFile, updatedContent); +