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: "

It works!

", + defaultValue: `

${Scratch.translate("It works!")}

`, }, }, }, @@ -151,23 +152,23 @@ { opcode: "show", blockType: Scratch.BlockType.COMMAND, - text: "show iframe", + text: Scratch.translate("show iframe"), }, { opcode: "hide", blockType: Scratch.BlockType.COMMAND, - text: "hide iframe", + text: Scratch.translate("hide iframe"), }, { opcode: "close", blockType: Scratch.BlockType.COMMAND, - text: "close iframe", + text: Scratch.translate("close iframe"), }, "---", { opcode: "get", blockType: Scratch.BlockType.REPORTER, - text: "iframe [MENU]", + text: Scratch.translate("iframe [MENU]"), arguments: { MENU: { type: Scratch.ArgumentType.STRING, @@ -178,7 +179,7 @@ { opcode: "setX", blockType: Scratch.BlockType.COMMAND, - text: "set iframe x position to [X]", + text: Scratch.translate("set iframe x position to [X]"), arguments: { X: { type: Scratch.ArgumentType.NUMBER, @@ -189,7 +190,7 @@ { opcode: "setY", blockType: Scratch.BlockType.COMMAND, - text: "set iframe y position to [Y]", + text: Scratch.translate("set iframe y position to [Y]"), arguments: { Y: { type: Scratch.ArgumentType.NUMBER, @@ -200,7 +201,7 @@ { opcode: "setWidth", blockType: Scratch.BlockType.COMMAND, - text: "set iframe width to [WIDTH]", + text: Scratch.translate("set iframe width to [WIDTH]"), arguments: { WIDTH: { type: Scratch.ArgumentType.NUMBER, @@ -211,7 +212,7 @@ { opcode: "setHeight", blockType: Scratch.BlockType.COMMAND, - text: "set iframe height to [HEIGHT]", + text: Scratch.translate("set iframe height to [HEIGHT]"), arguments: { HEIGHT: { type: Scratch.ArgumentType.NUMBER, @@ -222,7 +223,7 @@ { opcode: "setInteractive", blockType: Scratch.BlockType.COMMAND, - text: "set iframe interactive to [INTERACTIVE]", + text: Scratch.translate("set iframe interactive to [INTERACTIVE]"), arguments: { INTERACTIVE: { type: Scratch.ArgumentType.STRING, @@ -233,7 +234,7 @@ { opcode: "setResize", blockType: Scratch.BlockType.COMMAND, - text: "set iframe resize behavior to [RESIZE]", + text: Scratch.translate("set iframe resize behavior to [RESIZE]"), arguments: { RESIZE: { type: Scratch.ArgumentType.STRING, @@ -246,23 +247,36 @@ getMenu: { acceptReporters: true, items: [ - "url", - "visible", + Scratch.translate("url"), + Scratch.translate("visible"), "x", "y", - "width", - "height", - "interactive", - "resize behavior", + Scratch.translate("width"), + Scratch.translate("height"), + Scratch.translate("interactive"), + Scratch.translate("resize behavior"), ], }, interactiveMenu: { acceptReporters: true, - items: ["true", "false"], + items: [ + // The getter blocks will return English regardless of translating these + "true", + "false", + ], }, resizeMenu: { acceptReporters: true, - items: ["scale", "viewport"], + items: [ + { + text: Scratch.translate("scale"), + value: "scale", + }, + { + text: Scratch.translate("viewport"), + value: "viewport", + }, + ], }, }, }; diff --git a/extensions/lab/text.js b/extensions/lab/text.js index 5793d78c90..3c912fea53 100644 --- a/extensions/lab/text.js +++ b/extensions/lab/text.js @@ -601,25 +601,25 @@ getInfo() { return { id: "text", - name: "Animated Text", + name: Scratch.translate("Animated Text"), color1: "#9966FF", blockIconURI: blockIconURI, blocks: [ { opcode: "setText", blockType: Scratch.BlockType.COMMAND, - text: "show text [TEXT]", + text: Scratch.translate("show text [TEXT]"), arguments: { TEXT: { type: Scratch.ArgumentType.STRING, - defaultValue: "Welcome to my project!", + defaultValue: Scratch.translate("Welcome to my project!"), }, }, }, { opcode: "animateText", blockType: Scratch.BlockType.COMMAND, - text: "[ANIMATE] text [TEXT]", + text: Scratch.translate("[ANIMATE] text [TEXT]"), arguments: { ANIMATE: { type: Scratch.ArgumentType.STRING, @@ -628,20 +628,20 @@ }, TEXT: { type: Scratch.ArgumentType.STRING, - defaultValue: "Here we go!", + defaultValue: Scratch.translate("Here we go!"), }, }, }, { opcode: "clearText", blockType: Scratch.BlockType.COMMAND, - text: "show sprite", + text: Scratch.translate("show sprite"), }, "---", { opcode: "setFont", blockType: Scratch.BlockType.COMMAND, - text: "set font to [FONT]", + text: Scratch.translate("set font to [FONT]"), arguments: { FONT: { type: Scratch.ArgumentType.STRING, @@ -652,7 +652,7 @@ { opcode: "setColor", blockType: Scratch.BlockType.COMMAND, - text: "set text color to [COLOR]", + text: Scratch.translate("set text color to [COLOR]"), arguments: { COLOR: { type: Scratch.ArgumentType.COLOR, @@ -662,7 +662,7 @@ { opcode: "setWidth", blockType: Scratch.BlockType.COMMAND, - text: "set width to [WIDTH] aligned [ALIGN]", + text: Scratch.translate("set width to [WIDTH] aligned [ALIGN]"), arguments: { WIDTH: { type: Scratch.ArgumentType.NUMBER, @@ -684,18 +684,18 @@ { func: "disableCompatibilityMode", blockType: Scratch.BlockType.BUTTON, - text: "Enable Non-Scratch Lab Features", + text: Scratch.translate("Enable Non-Scratch Lab Features"), hideFromPalette: !compatibilityMode, }, { blockType: Scratch.BlockType.LABEL, - text: "Incompatible with Scratch Lab:", + text: Scratch.translate("Incompatible with Scratch Lab:"), hideFromPalette: compatibilityMode, }, { opcode: "setAlignment", blockType: Scratch.BlockType.COMMAND, - text: "align text to [ALIGN]", + text: Scratch.translate("align text to [ALIGN]"), hideFromPalette: compatibilityMode, arguments: { ALIGN: { @@ -708,7 +708,7 @@ // why is the other block called "setWidth" :( opcode: "setWidthValue", blockType: Scratch.BlockType.COMMAND, - text: "set width to [WIDTH]", + text: Scratch.translate("set width to [WIDTH]"), hideFromPalette: compatibilityMode, arguments: { WIDTH: { @@ -720,26 +720,26 @@ { opcode: "resetWidth", blockType: Scratch.BlockType.COMMAND, - text: "reset text width", + text: Scratch.translate("reset text width"), hideFromPalette: compatibilityMode, }, "---", { opcode: "addLine", blockType: Scratch.BlockType.COMMAND, - text: "add line [TEXT]", + text: Scratch.translate("add line [TEXT]"), hideFromPalette: compatibilityMode, arguments: { TEXT: { type: Scratch.ArgumentType.STRING, - defaultValue: "Hello!", + defaultValue: Scratch.translate("Hello!"), }, }, }, { opcode: "getLines", blockType: Scratch.BlockType.REPORTER, - text: "# of lines", + text: Scratch.translate("# of lines"), hideFromPalette: compatibilityMode, disableMonitor: true, }, @@ -747,7 +747,7 @@ { opcode: "startAnimate", blockType: Scratch.BlockType.COMMAND, - text: "start [ANIMATE] animation", + text: Scratch.translate("start [ANIMATE] animation"), hideFromPalette: compatibilityMode, arguments: { ANIMATE: { @@ -760,7 +760,7 @@ { opcode: "animateUntilDone", blockType: Scratch.BlockType.COMMAND, - text: "animate [ANIMATE] until done", + text: Scratch.translate("animate [ANIMATE] until done"), hideFromPalette: compatibilityMode, arguments: { ANIMATE: { @@ -773,7 +773,7 @@ { opcode: "isAnimating", blockType: Scratch.BlockType.BOOLEAN, - text: "is animating?", + text: Scratch.translate("is animating?"), hideFromPalette: compatibilityMode, disableMonitor: true, }, @@ -781,7 +781,7 @@ { opcode: "setAnimateDuration", blockType: Scratch.BlockType.COMMAND, - text: "set [ANIMATE] duration to [NUM] seconds", + text: Scratch.translate("set [ANIMATE] duration to [NUM] seconds"), hideFromPalette: compatibilityMode, arguments: { ANIMATE: { @@ -798,7 +798,7 @@ { opcode: "resetAnimateDuration", blockType: Scratch.BlockType.COMMAND, - text: "reset [ANIMATE] duration", + text: Scratch.translate("reset [ANIMATE] duration"), hideFromPalette: compatibilityMode, arguments: { ANIMATE: { @@ -811,7 +811,7 @@ { opcode: "getAnimateDuration", blockType: Scratch.BlockType.REPORTER, - text: "[ANIMATE] duration", + text: Scratch.translate("[ANIMATE] duration"), hideFromPalette: compatibilityMode, arguments: { ANIMATE: { @@ -825,7 +825,7 @@ { opcode: "setTypeDelay", blockType: Scratch.BlockType.COMMAND, - text: "set typing delay to [NUM] seconds", + text: Scratch.translate("set typing delay to [NUM] seconds"), hideFromPalette: compatibilityMode, arguments: { NUM: { @@ -837,13 +837,13 @@ { opcode: "resetTypeDelay", blockType: Scratch.BlockType.COMMAND, - text: "reset typing delay", + text: Scratch.translate("reset typing delay"), hideFromPalette: compatibilityMode, }, { opcode: "getTypeDelay", blockType: Scratch.BlockType.REPORTER, - text: "typing delay", + text: Scratch.translate("typing delay"), hideFromPalette: compatibilityMode, disableMonitor: true, }, @@ -851,21 +851,21 @@ { opcode: "textActive", blockType: Scratch.BlockType.BOOLEAN, - text: "is showing text?", + text: Scratch.translate("is showing text?"), hideFromPalette: compatibilityMode, disableMonitor: true, }, { opcode: "getDisplayedText", blockType: Scratch.BlockType.REPORTER, - text: "displayed text", + text: Scratch.translate("displayed text"), hideFromPalette: compatibilityMode, disableMonitor: true, }, { opcode: "getTextAttribute", blockType: Scratch.BlockType.REPORTER, - text: "text [ATTRIBUTE]", + text: Scratch.translate("text [ATTRIBUTE]"), arguments: { ATTRIBUTE: { type: Scratch.ArgumentType.STRING, @@ -880,7 +880,20 @@ // These all need acceptReporters: false for parity with the Scratch Labs version. animate: { acceptReporters: false, - items: ["type", "rainbow", "zoom"], + items: [ + { + text: Scratch.translate("type"), + value: "type", + }, + { + text: Scratch.translate("rainbow"), + value: "rainbow", + }, + { + text: Scratch.translate("zoom"), + value: "zoom", + }, + ], }, font: { acceptReporters: false, @@ -888,7 +901,20 @@ }, align: { acceptReporters: false, - items: ["left", "center", "right"], + items: [ + { + text: Scratch.translate("left"), + value: "left", + }, + { + text: Scratch.translate("center"), + value: "center", + }, + { + text: Scratch.translate("right"), + value: "right", + }, + ], }, attribute: { acceptReporters: false, @@ -897,15 +923,50 @@ // TurboWarp menus (acceptReporters: true) twAnimate: { acceptReporters: true, - items: ["type", "rainbow", "zoom"], + items: [ + { + text: Scratch.translate("type"), + value: "type", + }, + { + text: Scratch.translate("rainbow"), + value: "rainbow", + }, + { + text: Scratch.translate("zoom"), + value: "zoom", + }, + ], }, twAnimateDuration: { acceptReporters: true, - items: ["rainbow", "zoom"], + items: [ + { + text: Scratch.translate("rainbow"), + value: "rainbow", + }, + { + text: Scratch.translate("zoom"), + value: "zoom", + }, + ], }, twAlign: { acceptReporters: true, - items: ["left", "center", "right"], + items: [ + { + text: Scratch.translate("left"), + value: "left", + }, + { + text: Scratch.translate("center"), + value: "center", + }, + { + text: Scratch.translate("right"), + value: "right", + }, + ], }, }, }; @@ -923,7 +984,7 @@ ...FONTS, ...customFonts, { - text: "random font", + text: Scratch.translate("random font"), value: "Random", }, ]; @@ -1053,11 +1114,12 @@ */ disableCompatibilityMode() { - let popup = [ - "This will enable new blocks and features that WILL NOT WORK in the offical Scratch Lab.", - "Do you wish to continue?", - ]; - if (confirm(popup.join("\n\n"))) { + const popup = Scratch.translate({ + id: "disableCompatibilityMode", + default: + "This will enable new blocks and features that WILL NOT WORK in the offical Scratch Lab.\n\nDo you wish to continue?", + }); + if (confirm(popup)) { compatibilityMode = false; Scratch.vm.extensionManager.refreshBlocks(); } diff --git a/extensions/local-storage.js b/extensions/local-storage.js index 6d93321696..05cd0be63d 100644 --- a/extensions/local-storage.js +++ b/extensions/local-storage.js @@ -19,7 +19,9 @@ const valid = !!namespace; if (!valid && Date.now() - lastNamespaceWarning > 3000) { alert( - 'Local Storage extension: project must run the "set storage namespace ID" block before it can use other blocks' + Scratch.translate( + 'Local Storage extension: project must run the "set storage namespace ID" block before it can use other blocks' + ) ); lastNamespaceWarning = Date.now(); } @@ -90,39 +92,39 @@ getInfo() { return { id: "localstorage", - name: "Local Storage", + name: Scratch.translate("Local Storage"), docsURI: "https://extensions.turbowarp.org/local-storage", blocks: [ { opcode: "setProjectId", blockType: Scratch.BlockType.COMMAND, - text: "set storage namespace ID to [ID]", + text: Scratch.translate("set storage namespace ID to [ID]"), arguments: { ID: { type: Scratch.ArgumentType.STRING, - defaultValue: "project title", + defaultValue: Scratch.translate("project title"), }, }, }, { opcode: "get", blockType: Scratch.BlockType.REPORTER, - text: "get key [KEY]", + text: Scratch.translate("get key [KEY]"), arguments: { KEY: { type: Scratch.ArgumentType.STRING, - defaultValue: "score", + defaultValue: Scratch.translate("score"), }, }, }, { opcode: "set", blockType: Scratch.BlockType.COMMAND, - text: "set key [KEY] to [VALUE]", + text: Scratch.translate("set key [KEY] to [VALUE]"), arguments: { KEY: { type: Scratch.ArgumentType.STRING, - defaultValue: "score", + defaultValue: Scratch.translate("score"), }, VALUE: { type: Scratch.ArgumentType.STRING, @@ -133,23 +135,23 @@ { opcode: "remove", blockType: Scratch.BlockType.COMMAND, - text: "delete key [KEY]", + text: Scratch.translate("delete key [KEY]"), arguments: { KEY: { type: Scratch.ArgumentType.STRING, - defaultValue: "score", + defaultValue: Scratch.translate("score"), }, }, }, { opcode: "removeAll", blockType: Scratch.BlockType.COMMAND, - text: "delete all keys", + text: Scratch.translate("delete all keys"), }, { opcode: "whenChanged", blockType: Scratch.BlockType.EVENT, - text: "when another window changes storage", + text: Scratch.translate("when another window changes storage"), isEdgeActivated: false, }, ], diff --git a/extensions/navigator.js b/extensions/navigator.js index 0896c20a28..5424cb1976 100644 --- a/extensions/navigator.js +++ b/extensions/navigator.js @@ -1,6 +1,7 @@ // Name: Navigator // ID: navigatorinfo // Description: Details about the user's browser and operating system. +// Context: "Navigator" refers to someone's browser (function (Scratch) { "use strict"; @@ -9,27 +10,27 @@ getInfo() { return { id: "navigatorinfo", - name: "Navigator Info", + name: Scratch.translate("Navigator Info"), blocks: [ { opcode: "getOS", blockType: Scratch.BlockType.REPORTER, - text: "operating system", + text: Scratch.translate("operating system"), }, { opcode: "getBrowser", blockType: Scratch.BlockType.REPORTER, - text: "browser", + text: Scratch.translate("browser"), }, { opcode: "getMemory", blockType: Scratch.BlockType.REPORTER, - text: "device memory in GB", + text: Scratch.translate("device memory in GB"), }, { opcode: "getPreferredColorScheme", blockType: Scratch.BlockType.BOOLEAN, - text: "user prefers [THEME] color scheme?", + text: Scratch.translate("user prefers [THEME] color scheme?"), arguments: { THEME: { type: Scratch.ArgumentType.STRING, @@ -41,18 +42,27 @@ { opcode: "getPreferredReducedMotion", blockType: Scratch.BlockType.BOOLEAN, - text: "user prefers reduced motion?", + text: Scratch.translate("user prefers reduced motion?"), }, { opcode: "getPreferredContrast", blockType: Scratch.BlockType.BOOLEAN, - text: "user prefers more contrast?", + text: Scratch.translate("user prefers more contrast?"), }, ], menus: { THEME: { acceptReporters: true, - items: ["light", "dark"], + items: [ + { + text: Scratch.translate("light"), + value: "light", + }, + { + text: Scratch.translate("dark"), + value: "dark", + }, + ], }, }, }; diff --git a/extensions/pointerlock.js b/extensions/pointerlock.js index f106e6454c..1d5457bfb3 100644 --- a/extensions/pointerlock.js +++ b/extensions/pointerlock.js @@ -108,12 +108,12 @@ getInfo() { return { id: "pointerlock", - name: "Pointerlock", + name: Scratch.translate("Pointerlock"), blocks: [ { opcode: "setLocked", blockType: Scratch.BlockType.COMMAND, - text: "set pointer lock [enabled]", + text: Scratch.translate("set pointer lock [enabled]"), arguments: { enabled: { type: Scratch.ArgumentType.STRING, @@ -125,7 +125,7 @@ { opcode: "isLocked", blockType: Scratch.BlockType.BOOLEAN, - text: "pointer locked?", + text: Scratch.translate("pointer locked?"), }, ], menus: { @@ -133,11 +133,11 @@ acceptReporters: true, items: [ { - text: "enabled", + text: Scratch.translate("enabled"), value: "true", }, { - text: "disabled", + text: Scratch.translate("disabled"), value: "false", }, ], diff --git a/extensions/runtime-options.js b/extensions/runtime-options.js index 6e5134ad73..11a9d382a9 100644 --- a/extensions/runtime-options.js +++ b/extensions/runtime-options.js @@ -21,14 +21,14 @@ getInfo() { return { id: "runtimeoptions", - name: "Runtime Options", + name: Scratch.translate("Runtime Options"), color1: "#8c9abf", color2: "#7d8aab", color3: "#6f7b99", blocks: [ { opcode: "getEnabled", - text: "[thing] enabled?", + text: Scratch.translate("[thing] enabled?"), blockType: Scratch.BlockType.BOOLEAN, arguments: { thing: { @@ -40,7 +40,7 @@ }, { opcode: "setEnabled", - text: "set [thing] to [enabled]", + text: Scratch.translate("set [thing] to [enabled]"), blockType: Scratch.BlockType.COMMAND, arguments: { thing: { @@ -60,12 +60,12 @@ { opcode: "getFramerate", - text: "framerate limit", + text: Scratch.translate("framerate limit"), blockType: Scratch.BlockType.REPORTER, }, { opcode: "setFramerate", - text: "set framerate limit to [fps]", + text: Scratch.translate("set framerate limit to [fps]"), blockType: Scratch.BlockType.COMMAND, arguments: { fps: { @@ -79,12 +79,12 @@ { opcode: "getCloneLimit", - text: "clone limit", + text: Scratch.translate("clone limit"), blockType: Scratch.BlockType.REPORTER, }, { opcode: "setCloneLimit", - text: "set clone limit to [limit]", + text: Scratch.translate("set clone limit to [limit]"), blockType: Scratch.BlockType.COMMAND, arguments: { limit: { @@ -99,7 +99,10 @@ { opcode: "getDimension", - text: "stage [dimension]", + text: Scratch.translate({ + default: "stage [dimension]", + description: "[dimension] is a dropdown of width and height", + }), blockType: Scratch.BlockType.REPORTER, arguments: { dimension: { @@ -111,7 +114,9 @@ }, { opcode: "setDimensions", - text: "set stage size width: [width] height: [height]", + text: Scratch.translate( + "set stage size width: [width] height: [height]" + ), blockType: Scratch.BlockType.COMMAND, arguments: { width: { @@ -129,7 +134,7 @@ { opcode: "setUsername", - text: "set username to [username]", + text: Scratch.translate("set username to [username]"), blockType: Scratch.BlockType.COMMAND, arguments: { username: { @@ -140,7 +145,7 @@ }, { opcode: "greenFlag", - text: "run green flag [flag]", + text: Scratch.translate("run green flag [flag]"), blockType: Scratch.BlockType.COMMAND, arguments: { flag: { @@ -155,23 +160,23 @@ acceptReporters: true, items: [ { - text: "turbo mode", + text: Scratch.translate("turbo mode"), value: TURBO_MODE, }, { - text: "interpolation", + text: Scratch.translate("interpolation"), value: INTERPOLATION, }, { - text: "remove fencing", + text: Scratch.translate("remove fencing"), value: REMOVE_FENCING, }, { - text: "remove misc limits", + text: Scratch.translate("remove misc limits"), value: REMOVE_MISC_LIMITS, }, { - text: "high quality pen", + text: Scratch.translate("high quality pen"), value: HIGH_QUALITY_PEN, }, ], @@ -181,11 +186,11 @@ acceptReporters: true, items: [ { - text: "enabled", + text: Scratch.translate("enabled"), value: "true", }, { - text: "disabled", + text: Scratch.translate("disabled"), value: "false", }, ], @@ -195,11 +200,13 @@ acceptReporters: true, items: [ { - text: "default (300)", + text: Scratch.translate("default ({n})", { + n: "300", + }), value: "300", }, { - text: "Infinity", + text: Scratch.translate("Infinity"), value: "Infinity", }, ], @@ -209,11 +216,11 @@ acceptReporters: true, items: [ { - text: "width", + text: Scratch.translate("width"), value: "width", }, { - text: "height", + text: Scratch.translate("height"), value: "height", }, ], diff --git a/extensions/sound.js b/extensions/sound.js index f83a6e3341..baf1568ae5 100644 --- a/extensions/sound.js +++ b/extensions/sound.js @@ -167,12 +167,12 @@ return { // 'sound' would conflict with normal Scratch id: "notSound", - name: "Sound", + name: Scratch.translate("Sound"), blocks: [ { opcode: "play", blockType: Scratch.BlockType.COMMAND, - text: "start sound from url: [path]", + text: Scratch.translate("start sound from url: [path]"), arguments: { path: { type: Scratch.ArgumentType.STRING, @@ -183,7 +183,7 @@ { opcode: "playUntilDone", blockType: Scratch.BlockType.COMMAND, - text: "play sound from url: [path] until done", + text: Scratch.translate("play sound from url: [path] until done"), arguments: { path: { type: Scratch.ArgumentType.STRING, diff --git a/extensions/stretch.js b/extensions/stretch.js index 0446e2ceeb..233054f1db 100644 --- a/extensions/stretch.js +++ b/extensions/stretch.js @@ -52,7 +52,7 @@ getInfo() { return { id: "stretch", - name: "Stretch", + name: Scratch.translate("Stretch"), color1: "#4287f5", color2: "#2b62ba", color3: "#204785", @@ -60,7 +60,7 @@ { opcode: "setStretch", blockType: Scratch.BlockType.COMMAND, - text: "set stretch to x: [X] y: [Y]", + text: Scratch.translate("set stretch to x: [X] y: [Y]"), arguments: { X: { type: Scratch.ArgumentType.NUMBER, @@ -76,7 +76,7 @@ { opcode: "changeStretch", blockType: Scratch.BlockType.COMMAND, - text: "change stretch by x: [DX] y: [DY]", + text: Scratch.translate("change stretch by x: [DX] y: [DY]"), arguments: { DX: { type: Scratch.ArgumentType.NUMBER, @@ -94,7 +94,7 @@ { opcode: "setStretchX", blockType: Scratch.BlockType.COMMAND, - text: "set stretch x to [X]", + text: Scratch.translate("set stretch x to [X]"), arguments: { X: { type: Scratch.ArgumentType.NUMBER, @@ -106,7 +106,7 @@ { opcode: "setStretchY", blockType: Scratch.BlockType.COMMAND, - text: "set stretch y to [Y]", + text: Scratch.translate("set stretch y to [Y]"), arguments: { Y: { type: Scratch.ArgumentType.NUMBER, @@ -118,7 +118,7 @@ { opcode: "changeStretchX", blockType: Scratch.BlockType.COMMAND, - text: "change stretch x by [DX]", + text: Scratch.translate("change stretch x by [DX]"), arguments: { DX: { type: Scratch.ArgumentType.NUMBER, @@ -129,7 +129,7 @@ { opcode: "changeStretchY", blockType: Scratch.BlockType.COMMAND, - text: "change stretch y by [DY]", + text: Scratch.translate("change stretch y by [DY]"), arguments: { DY: { type: Scratch.ArgumentType.NUMBER, @@ -143,14 +143,14 @@ { opcode: "getX", blockType: Scratch.BlockType.REPORTER, - text: "x stretch", + text: Scratch.translate("x stretch"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, }, { opcode: "getY", blockType: Scratch.BlockType.REPORTER, - text: "y stretch", + text: Scratch.translate("y stretch"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, },