diff --git a/development/builder.js b/development/builder.js index 73dbca1bd0..d96572e154 100644 --- a/development/builder.js +++ b/development/builder.js @@ -648,8 +648,16 @@ class Build { generateL10N() { const allStrings = {}; - for (const file of Object.values(this.files)) { - const fileStrings = file.getStrings(); + for (const [filePath, file] of Object.entries(this.files)) { + let fileStrings; + try { + fileStrings = file.getStrings(); + } catch (error) { + console.error(error); + throw new Error( + `Error getting translations from ${filePath}: ${error}, see above` + ); + } if (!fileStrings) { continue; } diff --git a/development/parse-extension-translations.js b/development/parse-extension-translations.js index 624a7ca7c4..55e2570ff7 100644 --- a/development/parse-extension-translations.js +++ b/development/parse-extension-translations.js @@ -68,8 +68,8 @@ const parseTranslations = (js) => { const result = {}; for (const match of matches) { const args = match.arguments; - if (args.length !== 1) { - throw new Error(`Scratch.translate() must have exactly 1 argument`); + if (args.length === 0) { + throw new Error(`Scratch.translate() needs at least 1 argument`); } const evaluated = evaluateAST(args[0]); diff --git a/extensions/-SIPC-/consoles.js b/extensions/-SIPC-/consoles.js index 3454a518e1..9fca8f1d85 100644 --- a/extensions/-SIPC-/consoles.js +++ b/extensions/-SIPC-/consoles.js @@ -1,6 +1,6 @@ // Name: Consoles // ID: sipcconsole -// Description: Blocks that interact the JavaScript console built in to your browser's developer tools. +// Description: Blocks that interact with the JavaScript console built in to your browser's developer tools. // By: -SIPC- (function (Scratch) { diff --git a/extensions/.eslintrc.js b/extensions/.eslintrc.js index 969f9a4ef4..115a0a81cd 100644 --- a/extensions/.eslintrc.js +++ b/extensions/.eslintrc.js @@ -88,6 +88,18 @@ module.exports = { { selector: 'CallExpression[callee.object.object.name=Scratch][callee.object.property.name=translate][callee.property.name=setup]', message: 'Do not call Scratch.translate.setup() yourself. Just use Scratch.translate() and let the build script handle it.' + }, + { + selector: 'MethodDefinition[key.name=getInfo] Property[key.name=id][value.callee.property.name=translate]', + message: 'Do not translate extension ID' + }, + { + selector: 'MethodDefinition[key.name=docsURI] Property[key.name=id][value.callee.property.name=translate]', + message: 'Do not translate docsURI' + }, + { + selector: 'MethodDefinition[key.name=getInfo] Property[key.name=opcode][value.callee.property.name=translate]', + message: 'Do not translate block opcode' } ] } diff --git a/extensions/battery.js b/extensions/battery.js index fcb432b803..bda7f9ede6 100644 --- a/extensions/battery.js +++ b/extensions/battery.js @@ -61,51 +61,51 @@ class BatteryExtension { getInfo() { return { - name: "Battery", + name: Scratch.translate("Battery"), id: "battery", blocks: [ { opcode: "charging", blockType: Scratch.BlockType.BOOLEAN, - text: "charging?", + text: Scratch.translate("charging?"), }, { opcode: "level", blockType: Scratch.BlockType.REPORTER, - text: "battery level", + text: Scratch.translate("battery level"), }, { opcode: "chargeTime", blockType: Scratch.BlockType.REPORTER, - text: "seconds until charged", + text: Scratch.translate("seconds until charged"), }, { opcode: "dischargeTime", blockType: Scratch.BlockType.REPORTER, - text: "seconds until empty", + text: Scratch.translate("seconds until empty"), }, { opcode: "chargingChanged", blockType: Scratch.BlockType.EVENT, - text: "when charging changed", + text: Scratch.translate("when charging changed"), isEdgeActivated: false, }, { opcode: "levelChanged", blockType: Scratch.BlockType.EVENT, - text: "when battery level changed", + text: Scratch.translate("when battery level changed"), isEdgeActivated: false, }, { opcode: "chargeTimeChanged", blockType: Scratch.BlockType.EVENT, - text: "when time until charged changed", + text: Scratch.translate("when time until charged changed"), isEdgeActivated: false, }, { opcode: "dischargeTimeChanged", blockType: Scratch.BlockType.EVENT, - text: "when time until empty changed", + text: Scratch.translate("when time until empty changed"), isEdgeActivated: false, }, ], diff --git a/extensions/box2d.js b/extensions/box2d.js index b6dbe689fd..ad14eadc58 100644 --- a/extensions/box2d.js +++ b/extensions/box2d.js @@ -12119,8 +12119,6 @@ // const Cast = require('../../util/cast'); // const Runtime = require('../../engine/runtime'); // const RenderedTarget = require('../../sprites/rendered-target'); - // const formatMessage = require('format-message'); - const formatMessage = (obj) => obj.default; // const MathUtil = require('../../util/math-util'); // const Timer = require('../../util/timer'); // const Matter = require('matterJs/matter'); @@ -12506,7 +12504,7 @@ getInfo() { return { id: "griffpatch", - name: formatMessage({ + name: Scratch.translate({ id: "griffpatch.categoryName", default: "Physics", description: "Label for the Griffpatch extension category", @@ -12520,7 +12518,7 @@ { opcode: "setStage", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setStage", default: "set stage boundaries to [stageType]", description: "Set the stage type", @@ -12536,7 +12534,7 @@ { opcode: "setGravity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setGravity", default: "set gravity to x: [gx] y: [gy]", description: "Set the gravity", @@ -12555,7 +12553,7 @@ { opcode: "getGravityX", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getGravityX", default: "gravity x", description: "Get the gravity's x value", @@ -12564,7 +12562,7 @@ { opcode: "getGravityY", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getGravityY", default: "gravity y", description: "Get the gravity's y value", @@ -12576,7 +12574,7 @@ { opcode: "setPhysics", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setPhysics", default: "enable for [shape] mode [mode]", description: "Enable Physics for this Sprite", @@ -12598,7 +12596,7 @@ // { // opcode: 'setPhysics', // blockType: BlockType.COMMAND, - // text: formatMessage({ + // text: Scratch.translate({ // id: 'griffpatch.setPhysics', // default: 'enable physics for sprite [shape]', // description: 'Enable Physics for this Sprite' @@ -12614,7 +12612,7 @@ // { // opcode: 'setPhysicsAll', // blockType: BlockType.COMMAND, - // text: formatMessage({ + // text: Scratch.translate({ // id: 'griffpatch.setPhysicsAll', // default: 'enable physics for all sprites', // description: 'Enable Physics For All Sprites' @@ -12626,7 +12624,7 @@ { opcode: "doTick", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.doTick", default: "step simulation", description: "Run a single tick of the physics simulation", @@ -12638,7 +12636,7 @@ { opcode: "setPosition", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setPosition", default: "go to x: [x] y: [y] [space]", description: "Position Sprite", @@ -12669,7 +12667,7 @@ { opcode: "setVelocity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setVelocity", default: "set velocity to sx: [sx] sy: [sy]", description: "Set Velocity", @@ -12689,7 +12687,7 @@ { opcode: "changeVelocity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.changeVelocity", default: "change velocity by sx: [sx] sy: [sy]", description: "Change Velocity", @@ -12708,7 +12706,7 @@ }, { opcode: "getVelocityX", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getVelocityX", default: "x velocity", description: "get the x velocity", @@ -12718,7 +12716,7 @@ }, { opcode: "getVelocityY", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getVelocityY", default: "y velocity", description: "get the y velocity", @@ -12732,7 +12730,7 @@ { opcode: "applyForce", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.applyForce", default: "push with force [force] in direction [dir]", description: "Push this object in a given direction", @@ -12752,7 +12750,7 @@ { opcode: "applyAngForce", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.applyAngForce", default: "spin with force [force]", description: "Push this object in a given direction", @@ -12771,7 +12769,7 @@ { opcode: "setAngVelocity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setAngVelocity", default: "set angular velocity to [force]", description: "Set the angular velocity of the sprite", @@ -12787,7 +12785,7 @@ { opcode: "getAngVelocity", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getAngVelocity", default: "angular velocity", description: "Get the angular velocity of the sprite", @@ -12800,7 +12798,7 @@ { opcode: "setStatic", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setStatic", default: "set fixed to [static]", description: "Sets whether this block is static or dynamic", @@ -12816,7 +12814,7 @@ }, { opcode: "getStatic", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getStatic", default: "fixed?", description: "get whether this sprite is fixed", @@ -12831,7 +12829,7 @@ { opcode: "setDensity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setDensity", default: "set density to [density]", description: "Set the density of the object", @@ -12849,7 +12847,7 @@ opcode: "setDensityValue", func: "setDensity", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setDensityValue", default: "set density to [density]", description: "Set the density of the object", @@ -12865,7 +12863,7 @@ { opcode: "getDensity", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getDensity", default: "density", description: "Get the density of the object", @@ -12878,7 +12876,7 @@ { opcode: "setFriction", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setFriction", default: "set friction to [friction]", description: "Set the friction of the object", @@ -12896,7 +12894,7 @@ opcode: "setFrictionValue", func: "setFriction", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setFrictionValue", default: "set friction to [friction]", description: "Set the friction value of the object", @@ -12912,7 +12910,7 @@ { opcode: "getFriction", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getFriction", default: "friction", description: "Get the friction of the object", @@ -12925,7 +12923,7 @@ { opcode: "setRestitution", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setRestitution", default: "set bounce to [restitution]", description: "Set the bounce of the object", @@ -12943,7 +12941,7 @@ opcode: "setRestitutionValue", func: "setRestitution", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setRestitutionValue", default: "set bounce to [restitution]", description: "Set the bounce value of the object", @@ -12959,7 +12957,7 @@ { opcode: "getRestitution", blockType: BlockType.REPORTER, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getRestitution", default: "bounce", description: "Get the bounce value of the object", @@ -12972,7 +12970,7 @@ { opcode: "setProperties", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setProperties", default: "set density [density] roughness [friction] bounce [restitution]", @@ -13001,7 +12999,7 @@ // { // opcode: 'pinSprite', // blockType: BlockType.COMMAND, - // text: formatMessage({ + // text: Scratch.translate({ // id: 'griffpatch.pinSprite', // default: 'pin to world at sprite\'s x: [x] y: [y]', // description: 'Pin the sprite' @@ -13022,7 +13020,7 @@ { opcode: "getTouching", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getTouching", default: "list sprites touching [where]", description: "get the name of any sprites we are touching", @@ -13045,7 +13043,7 @@ { opcode: "setScroll", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.setScroll", default: "set scroll to x: [ox] y: [oy]", description: "Sets whether this block is static or dynamic", @@ -13064,7 +13062,7 @@ { opcode: "changeScroll", blockType: BlockType.COMMAND, - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.changeScroll", default: "change scroll by x: [ox] y: [oy]", description: "Sets whether this block is static or dynamic", @@ -13082,7 +13080,7 @@ }, { opcode: "getScrollX", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getScrollX", default: "x scroll", description: "get the x scroll", @@ -13091,7 +13089,7 @@ }, { opcode: "getScrollY", - text: formatMessage({ + text: Scratch.translate({ id: "griffpatch.getScrollY", default: "y scroll", description: "get the y scroll", diff --git a/extensions/clipboard.js b/extensions/clipboard.js index 07f1752857..ddde09bcf2 100644 --- a/extensions/clipboard.js +++ b/extensions/clipboard.js @@ -44,7 +44,7 @@ getInfo() { return { id: "clipboard", - name: "Clipboard", + name: Scratch.translate("Clipboard"), blockIconURI: extensionicon, color1: "#008080", color2: "#006666", @@ -52,20 +52,20 @@ { opcode: "whenCopied", blockType: Scratch.BlockType.EVENT, - text: "when something is copied", + text: Scratch.translate("when something is copied"), isEdgeActivated: false, }, { opcode: "whenPasted", blockType: Scratch.BlockType.EVENT, - text: "when something is pasted", + text: Scratch.translate("when something is pasted"), isEdgeActivated: false, }, "---", { opcode: "setClipboard", blockType: Scratch.BlockType.COMMAND, - text: "copy to clipboard: [TEXT]", + text: Scratch.translate("copy to clipboard: [TEXT]"), arguments: { TEXT: { type: Scratch.ArgumentType.STRING, @@ -75,19 +75,19 @@ { opcode: "resetClipboard", blockType: Scratch.BlockType.COMMAND, - text: "reset clipboard", + text: Scratch.translate("reset clipboard"), }, "---", { opcode: "clipboard", blockType: Scratch.BlockType.REPORTER, - text: "clipboard", + text: Scratch.translate("clipboard"), disableMonitor: true, }, { opcode: "getLastPastedText", blockType: Scratch.BlockType.REPORTER, - text: "last pasted text", + text: Scratch.translate("last pasted text"), disableMonitor: true, }, ], diff --git a/extensions/clouddata-ping.js b/extensions/clouddata-ping.js index 93a130de1e..f7d60db590 100644 --- a/extensions/clouddata-ping.js +++ b/extensions/clouddata-ping.js @@ -97,12 +97,12 @@ getInfo() { return { id: "clouddataping", - name: "Ping Cloud Data", + name: Scratch.translate("Ping Cloud Data"), blocks: [ { opcode: "ping", blockType: Scratch.BlockType.BOOLEAN, - text: "is cloud data server [SERVER] up?", + text: Scratch.translate("is cloud data server [SERVER] up?"), arguments: { SERVER: { type: Scratch.ArgumentType.STRING, diff --git a/extensions/cursor.js b/extensions/cursor.js index ae478f76aa..a8a25f6fb6 100644 --- a/extensions/cursor.js +++ b/extensions/cursor.js @@ -140,6 +140,19 @@ return [+a || 0, +b || 0]; }; + /** + * @param {string} size eg. "48x84" + * @returns {string} + */ + const formatUnreliableSize = (size) => + Scratch.translate( + { + default: "{size} (unreliable)", + description: "[size] is replaced with a size in pixels such as '48x48'", + }, + { size } + ); + const cursors = [ "default", "pointer", @@ -188,12 +201,12 @@ getInfo() { return { id: "MouseCursor", - name: "Mouse Cursor", + name: Scratch.translate("Mouse Cursor"), blocks: [ { opcode: "setCur", blockType: Scratch.BlockType.COMMAND, - text: "set cursor to [cur]", + text: Scratch.translate("set cursor to [cur]"), arguments: { cur: { type: Scratch.ArgumentType.STRING, @@ -205,7 +218,9 @@ { opcode: "setCursorImage", blockType: Scratch.BlockType.COMMAND, - text: "set cursor to current costume center: [position] max size: [size]", + text: Scratch.translate( + "set cursor to current costume center: [position] max size: [size]" + ), arguments: { position: { type: Scratch.ArgumentType.STRING, @@ -222,12 +237,12 @@ { opcode: "hideCur", blockType: Scratch.BlockType.COMMAND, - text: "hide cursor", + text: Scratch.translate("hide cursor"), }, { opcode: "getCur", blockType: Scratch.BlockType.REPORTER, - text: "cursor", + text: Scratch.translate("cursor"), }, ], menus: { @@ -239,11 +254,11 @@ acceptReporters: true, items: [ // [x, y] where x is [0=left, 100=right] and y is [0=top, 100=bottom] - { text: "top left", value: "0,0" }, - { text: "top right", value: "100,0" }, - { text: "bottom left", value: "0,100" }, - { text: "bottom right", value: "100,100" }, - { text: "center", value: "50,50" }, + { text: Scratch.translate("top left"), value: "0,0" }, + { text: Scratch.translate("top right"), value: "100,0" }, + { text: Scratch.translate("bottom left"), value: "0,100" }, + { text: Scratch.translate("bottom right"), value: "100,100" }, + { text: Scratch.translate("center"), value: "50,50" }, ], }, imageSizes: { @@ -257,9 +272,9 @@ { text: "12x12", value: "12x12" }, { text: "16x16", value: "16x16" }, { text: "32x32", value: "32x32" }, - { text: "48x48 (unreliable)", value: "48x48" }, - { text: "64x64 (unreliable)", value: "64x64" }, - { text: "128x128 (unreliable)", value: "128x128" }, + { text: formatUnreliableSize("48x48"), value: "48x48" }, + { text: formatUnreliableSize("64x64"), value: "64x64" }, + { text: formatUnreliableSize("128x128"), value: "128x128" }, ], }, }, diff --git a/extensions/encoding.js b/extensions/encoding.js index f506508052..d561267088 100644 --- a/extensions/encoding.js +++ b/extensions/encoding.js @@ -414,7 +414,7 @@ getInfo() { return { id: "Encoding", - name: "Encoding", + name: Scratch.translate("Encoding"), color1: "#6495ed", color2: "#739fee", color3: "#83aaf0", @@ -424,7 +424,7 @@ { opcode: "encode", blockType: Scratch.BlockType.REPORTER, - text: "Encode [string] in [code]", + text: Scratch.translate("Encode [string] in [code]"), arguments: { string: { type: Scratch.ArgumentType.STRING, @@ -440,11 +440,11 @@ { opcode: "decode", blockType: Scratch.BlockType.REPORTER, - text: "Decode [string] with [code]", + text: Scratch.translate("Decode [string] with [code]"), arguments: { string: { type: Scratch.ArgumentType.STRING, - defaultValue: "VHVyYm9XYXJw", + defaultValue: btoa(Scratch.translate("apple")), }, code: { type: Scratch.ArgumentType.STRING, @@ -456,11 +456,11 @@ { opcode: "hash", blockType: Scratch.BlockType.REPORTER, - text: "Hash [string] with [hash]", + text: Scratch.translate("Hash [string] with [hash]"), arguments: { string: { type: Scratch.ArgumentType.STRING, - defaultValue: "apple", + defaultValue: Scratch.translate("apple"), }, hash: { type: Scratch.ArgumentType.STRING, @@ -475,7 +475,9 @@ { opcode: "Conversioncodes", blockType: Scratch.BlockType.REPORTER, - text: "Convert the character [string] to [CodeList]", + text: Scratch.translate( + "Convert the character [string] to [CodeList]" + ), arguments: { string: { type: Scratch.ArgumentType.STRING, @@ -491,7 +493,9 @@ { opcode: "Restorecode", blockType: Scratch.BlockType.REPORTER, - text: "[string] corresponding to the [CodeList] character", + text: Scratch.translate( + "[string] corresponding to the [CodeList] character" + ), arguments: { string: { type: Scratch.ArgumentType.STRING, @@ -510,7 +514,9 @@ { opcode: "Randomstrings", blockType: Scratch.BlockType.REPORTER, - text: "Randomly generated [position] character string", + text: Scratch.translate( + "Randomly generated [position] character string" + ), arguments: { position: { type: Scratch.ArgumentType.NUMBER, @@ -521,7 +527,9 @@ { opcode: "Fontgenerationstring", blockType: Scratch.BlockType.REPORTER, - text: "Use [wordbank] to generate a random [position] character string", + text: Scratch.translate( + "Use [wordbank] to generate a random [position] character string" + ), arguments: { wordbank: { type: Scratch.ArgumentType.STRING, diff --git a/extensions/fetch.js b/extensions/fetch.js index 10ff8e13e4..92e76abc7b 100644 --- a/extensions/fetch.js +++ b/extensions/fetch.js @@ -9,7 +9,7 @@ getInfo() { return { id: "fetch", - name: "Fetch", + name: Scratch.translate("Fetch"), blocks: [ { opcode: "get", diff --git a/extensions/files.js b/extensions/files.js index 686906f150..be3b6fd0b5 100644 --- a/extensions/files.js +++ b/extensions/files.js @@ -164,14 +164,23 @@ }); const title = document.createElement("div"); - title.textContent = "Select or drop file"; + title.textContent = Scratch.translate("Select or drop file"); title.style.fontSize = "1.5em"; title.style.marginBottom = "8px"; modal.appendChild(title); const subtitle = document.createElement("div"); - const formattedAccept = accept || "any"; - subtitle.textContent = `Accepted formats: ${formattedAccept}`; + const formattedAccept = accept || Scratch.translate("any"); + subtitle.textContent = Scratch.translate( + { + default: "Accepted formats: {formats}", + description: + "[formats] is replaced with a comma-separated list of file types eg: .txt, .mp3, .png or the word any", + }, + { + formats: formattedAccept, + } + ); modal.appendChild(subtitle); // To avoid the script getting stalled forever, if cancel isn't supported, we'll just forcibly @@ -260,7 +269,7 @@ getInfo() { return { id: "files", - name: "Files", + name: Scratch.translate("Files"), color1: "#fcb103", color2: "#db9a37", color3: "#db8937", @@ -268,14 +277,14 @@ { opcode: "showPicker", blockType: Scratch.BlockType.REPORTER, - text: "open a file", + text: Scratch.translate("open a file"), disableMonitor: true, hideFromPalette: true, }, { opcode: "showPickerExtensions", blockType: Scratch.BlockType.REPORTER, - text: "open a [extension] file", + text: Scratch.translate("open a [extension] file"), arguments: { extension: { type: Scratch.ArgumentType.STRING, @@ -288,7 +297,7 @@ { opcode: "showPickerAs", blockType: Scratch.BlockType.REPORTER, - text: "open a file as [as]", + text: Scratch.translate("open a file as [as]"), arguments: { as: { type: Scratch.ArgumentType.STRING, @@ -299,7 +308,7 @@ { opcode: "showPickerExtensionsAs", blockType: Scratch.BlockType.REPORTER, - text: "open a [extension] file as [as]", + text: Scratch.translate("open a [extension] file as [as]"), arguments: { extension: { type: Scratch.ArgumentType.STRING, @@ -317,22 +326,22 @@ { opcode: "download", blockType: Scratch.BlockType.COMMAND, - text: "download [text] as [file]", + text: Scratch.translate("download [text] as [file]"), arguments: { text: { type: Scratch.ArgumentType.STRING, - defaultValue: "Hello, world!", + defaultValue: Scratch.translate("Hello, world!"), }, file: { type: Scratch.ArgumentType.STRING, - defaultValue: "save.txt", + defaultValue: Scratch.translate("save.txt"), }, }, }, { opcode: "downloadURL", blockType: Scratch.BlockType.COMMAND, - text: "download URL [url] as [file]", + text: Scratch.translate("download URL [url] as [file]"), arguments: { url: { type: Scratch.ArgumentType.STRING, @@ -340,7 +349,7 @@ }, file: { type: Scratch.ArgumentType.STRING, - defaultValue: "save.txt", + defaultValue: Scratch.translate("save.txt"), }, }, }, @@ -350,7 +359,7 @@ { opcode: "setOpenMode", blockType: Scratch.BlockType.COMMAND, - text: "set open file selector mode to [mode]", + text: Scratch.translate("set open file selector mode to [mode]"), arguments: { mode: { type: Scratch.ArgumentType.STRING, @@ -365,7 +374,7 @@ acceptReporters: true, items: [ { - text: "text", + text: Scratch.translate("text"), value: AS_TEXT, }, { @@ -378,16 +387,16 @@ acceptReporters: true, items: [ { - text: "show modal", + text: Scratch.translate("show modal"), value: MODE_MODAL, }, { - text: "open selector immediately", + text: Scratch.translate("open selector immediately"), value: MODE_IMMEDIATELY_SHOW_SELECTOR, }, { // Will not work if the browser doesn't think we are responding to a click event. - text: "only show selector (unreliable)", + text: Scratch.translate("only show selector (unreliable)"), value: MODE_ONLY_SELECTOR, }, ], diff --git a/extensions/gamepad.js b/extensions/gamepad.js index ada40f8604..3b2e7a8ba0 100644 --- a/extensions/gamepad.js +++ b/extensions/gamepad.js @@ -79,12 +79,12 @@ getInfo() { return { id: "Gamepad", - name: "Gamepad", + name: Scratch.translate("Gamepad"), blocks: [ { opcode: "gamepadConnected", blockType: Scratch.BlockType.BOOLEAN, - text: "gamepad [pad] connected?", + text: Scratch.translate("gamepad [pad] connected?"), arguments: { pad: { type: Scratch.ArgumentType.NUMBER, @@ -96,7 +96,7 @@ { opcode: "buttonDown", blockType: Scratch.BlockType.BOOLEAN, - text: "button [b] on pad [i] pressed?", + text: Scratch.translate("button [b] on pad [i] pressed?"), arguments: { b: { type: Scratch.ArgumentType.NUMBER, @@ -113,7 +113,7 @@ { opcode: "buttonValue", blockType: Scratch.BlockType.REPORTER, - text: "value of button [b] on pad [i]", + text: Scratch.translate("value of button [b] on pad [i]"), arguments: { b: { type: Scratch.ArgumentType.NUMBER, @@ -130,7 +130,7 @@ { opcode: "axisValue", blockType: Scratch.BlockType.REPORTER, - text: "value of axis [b] on pad [i]", + text: Scratch.translate("value of axis [b] on pad [i]"), arguments: { b: { type: Scratch.ArgumentType.NUMBER, @@ -150,7 +150,7 @@ { opcode: "axisDirection", blockType: Scratch.BlockType.REPORTER, - text: "direction of axes [axis] on pad [pad]", + text: Scratch.translate("direction of axes [axis] on pad [pad]"), arguments: { axis: { type: Scratch.ArgumentType.NUMBER, @@ -167,7 +167,7 @@ { opcode: "axisMagnitude", blockType: Scratch.BlockType.REPORTER, - text: "magnitude of axes [axis] on pad [pad]", + text: Scratch.translate("magnitude of axes [axis] on pad [pad]"), arguments: { axis: { type: Scratch.ArgumentType.NUMBER, @@ -186,7 +186,7 @@ { opcode: 'buttonPressedReleased', blockType: Scratch.BlockType.EVENT, - text: 'button [b] [pr] of pad [i]', + text: Scratch.translate('button [b] [pr] of pad [i]'), arguments: { b: { type: Scratch.ArgumentType.NUMBER, @@ -208,7 +208,7 @@ { opcode: 'axisMoved', blockType: Scratch.BlockType.EVENT, - text: 'axis [b] of pad [i] moved', + text: Scratch.translate('axis [b] of pad [i] moved'), arguments: { b: { type: Scratch.ArgumentType.NUMBER, @@ -228,7 +228,9 @@ { opcode: "rumble", blockType: Scratch.BlockType.COMMAND, - text: "rumble strong [s] and weak [w] for [t] sec. on pad [i]", + text: Scratch.translate( + "rumble strong [s] and weak [w] for [t] sec. on pad [i]" + ), arguments: { s: { type: Scratch.ArgumentType.NUMBER, @@ -255,7 +257,7 @@ acceptReporters: true, items: [ { - text: "any", + text: Scratch.translate("any"), value: "any", }, { @@ -281,7 +283,7 @@ items: [ // Based on an Xbox controller { - text: "any", + text: Scratch.translate("any"), value: "any", }, { @@ -301,51 +303,51 @@ value: "4", }, { - text: "Left bumper (5)", + text: Scratch.translate("Left bumper (5)"), value: "5", }, { - text: "Right bumper (6)", + text: Scratch.translate("Right bumper (6)"), value: "6", }, { - text: "Left trigger (7)", + text: Scratch.translate("Left trigger (7)"), value: "7", }, { - text: "Right trigger (8)", + text: Scratch.translate("Right trigger (8)"), value: "8", }, { - text: "Select/View (9)", + text: Scratch.translate("Select/View (9)"), value: "9", }, { - text: "Start/Menu (10)", + text: Scratch.translate("Start/Menu (10)"), value: "10", }, { - text: "Left stick (11)", + text: Scratch.translate("Left stick (11)"), value: "11", }, { - text: "Right stick (12)", + text: Scratch.translate("Right stick (12)"), value: "12", }, { - text: "D-pad up (13)", + text: Scratch.translate("D-pad up (13)"), value: "13", }, { - text: "D-pad down (14)", + text: Scratch.translate("D-pad down (14)"), value: "14", }, { - text: "D-pad left (15)", + text: Scratch.translate("D-pad left (15)"), value: "15", }, { - text: "D-pad right (16)", + text: Scratch.translate("D-pad right (16)"), value: "16", }, ], @@ -355,19 +357,19 @@ items: [ // Based on an Xbox controller { - text: "Left stick horizontal (1)", + text: Scratch.translate("Left stick horizontal (1)"), value: "1", }, { - text: "Left stick vertical (2)", + text: Scratch.translate("Left stick vertical (2)"), value: "2", }, { - text: "Right stick horizontal (3)", + text: Scratch.translate("Right stick horizontal (3)"), value: "3", }, { - text: "Right stick vertical (4)", + text: Scratch.translate("Right stick vertical (4)"), value: "4", }, ], @@ -377,11 +379,11 @@ items: [ // Based on an Xbox controller { - text: "Left stick (1 & 2)", + text: Scratch.translate("Left stick (1 & 2)"), value: "1", }, { - text: "Right stick (3 & 4)", + text: Scratch.translate("Right stick (3 & 4)"), value: "3", }, ], @@ -389,11 +391,11 @@ /* pressReleaseMenu: [ { - text: 'press', + text: Scratch.translate('press'), value: 1 }, { - text: 'release', + text: Scratch.translate('release'), value: 0 } ], diff --git a/extensions/iframe.js b/extensions/iframe.js index 29224ef9d6..ce87728a2c 100644 --- a/extensions/iframe.js +++ b/extensions/iframe.js @@ -1,6 +1,7 @@ // Name: Iframe // ID: iframe // Description: Display webpages or HTML over the stage. +// Context: "iframe" is an HTML element that lets websites embed other websites. (function (Scratch) { "use strict"; @@ -122,13 +123,13 @@ class IframeExtension { getInfo() { return { - name: "Iframe", + name: Scratch.translate("Iframe"), id: "iframe", blocks: [ { opcode: "display", blockType: Scratch.BlockType.COMMAND, - text: "show website [URL]", + text: Scratch.translate("show website [URL]"), arguments: { URL: { type: Scratch.ArgumentType.STRING, @@ -139,11 +140,11 @@ { opcode: "displayHTML", blockType: Scratch.BlockType.COMMAND, - text: "show HTML [HTML]", + text: Scratch.translate("show HTML [HTML]"), arguments: { HTML: { type: Scratch.ArgumentType.STRING, - defaultValue: "