From 02e255be0e16b59a19bd05bde7d3db5e9e5c6970 Mon Sep 17 00:00:00 2001 From: qxs_ck Date: Sun, 19 May 2024 10:08:44 +0800 Subject: [PATCH] Add translations to TempVar, TempVar2, ClonesPlus (#1477) --- extensions/Lily/ClonesPlus.js | 81 +++++++++++++++++++------------ extensions/Lily/TempVariables.js | 14 +++--- extensions/Lily/TempVariables2.js | 32 ++++++------ 3 files changed, 74 insertions(+), 53 deletions(-) diff --git a/extensions/Lily/ClonesPlus.js b/extensions/Lily/ClonesPlus.js index e3c37f616d..21fb181f53 100644 --- a/extensions/Lily/ClonesPlus.js +++ b/extensions/Lily/ClonesPlus.js @@ -48,7 +48,7 @@ getInfo() { return { id: "lmsclonesplus", - name: "Clones+", + name: Scratch.translate("Clones+"), color1: "#FFAB19", color2: "#EC9C13", color3: "#CF8B17", @@ -57,7 +57,9 @@ { opcode: "whenCloneStartsWithVar", blockType: Scratch.BlockType.HAT, - text: "when I start as a clone with [INPUTA] set to [INPUTB]", + text: Scratch.translate( + "when I start as a clone with [INPUTA] set to [INPUTB]" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -74,7 +76,9 @@ { opcode: "createCloneWithVar", blockType: Scratch.BlockType.COMMAND, - text: "create clone with [INPUTA] set to [INPUTB]", + text: Scratch.translate( + "create clone with [INPUTA] set to [INPUTB]" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -94,7 +98,9 @@ { opcode: "touchingCloneWithVar", blockType: Scratch.BlockType.BOOLEAN, - text: "touching clone with [INPUTA] set to [INPUTB]?", + text: Scratch.translate( + "touching clone with [INPUTA] set to [INPUTB]?" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -111,7 +117,7 @@ { opcode: "touchingMainSprite", blockType: Scratch.BlockType.BOOLEAN, - text: "touching main sprite?", + text: Scratch.translate("touching main sprite?"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, extensions: ["colours_control"], @@ -122,7 +128,9 @@ { opcode: "setVariableOfClone", blockType: Scratch.BlockType.COMMAND, - text: "set variable [INPUTA] to [INPUTB] for clones with [INPUTC] set to [INPUTD]", + text: Scratch.translate( + "set variable [INPUTA] to [INPUTB] for clones with [INPUTC] set to [INPUTD]" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -147,7 +155,9 @@ { opcode: "getVariableOfClone", blockType: Scratch.BlockType.REPORTER, - text: "variable [INPUTA] of clone with [INPUTB] set to [INPUTC]", + text: Scratch.translate( + "variable [INPUTA] of clone with [INPUTB] set to [INPUTC]" + ), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, arguments: { @@ -169,7 +179,9 @@ { opcode: "setVariableOfMainSprite", blockType: Scratch.BlockType.COMMAND, - text: "set variable [INPUTA] to [INPUTB] for main sprite", + text: Scratch.translate( + "set variable [INPUTA] to [INPUTB] for main sprite" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -186,7 +198,7 @@ { opcode: "getVariableOfMainSprite", blockType: Scratch.BlockType.REPORTER, - text: "variable [INPUT] of main sprite", + text: Scratch.translate("variable [INPUT] of main sprite"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, arguments: { @@ -203,7 +215,9 @@ { opcode: "cloneExists", blockType: Scratch.BlockType.BOOLEAN, - text: "clone with [INPUTA] set to [INPUTB] exists?", + text: Scratch.translate( + "clone with [INPUTA] set to [INPUTB] exists?" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -220,13 +234,14 @@ { opcode: "getThingOfClone", blockType: Scratch.BlockType.REPORTER, - text: "[INPUTA] of clone with [INPUTB] set to [INPUTC]", + text: Scratch.translate( + "[INPUTA] of clone with [INPUTB] set to [INPUTC]" + ), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, arguments: { INPUTA: { type: Scratch.ArgumentType.STRING, - defaultValue: "x position", menu: "thingOfMenu", }, INPUTB: { @@ -243,13 +258,12 @@ { opcode: "getThingOfMainSprite", blockType: Scratch.BlockType.REPORTER, - text: "[INPUT] of main sprite", + text: Scratch.translate("[INPUT] of main sprite"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, arguments: { INPUT: { type: Scratch.ArgumentType.STRING, - defaultValue: "x position", menu: "thingOfMenu", }, }, @@ -261,7 +275,7 @@ { opcode: "stopScriptsInSprite", blockType: Scratch.BlockType.COMMAND, - text: "stop scripts in [INPUT]", + text: Scratch.translate("stop scripts in [INPUT]"), arguments: { INPUT: { type: Scratch.ArgumentType.STRING, @@ -273,7 +287,9 @@ { opcode: "stopScriptsInClone", blockType: Scratch.BlockType.COMMAND, - text: "stop scripts in clones with [INPUTA] set to [INPUTB]", + text: Scratch.translate( + "stop scripts in clones with [INPUTA] set to [INPUTB]" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -290,7 +306,7 @@ { opcode: "stopScriptsInMainSprite", blockType: Scratch.BlockType.COMMAND, - text: "stop scripts in main sprite", + text: Scratch.translate("stop scripts in main sprite"), filter: [Scratch.TargetType.SPRITE], extensions: ["colours_control"], }, @@ -300,7 +316,7 @@ { opcode: "deleteClonesInSprite", blockType: Scratch.BlockType.COMMAND, - text: "delete clones in [INPUT]", + text: Scratch.translate("delete clones in [INPUT]"), arguments: { INPUT: { type: Scratch.ArgumentType.STRING, @@ -312,7 +328,9 @@ { opcode: "deleteCloneWithVar", blockType: Scratch.BlockType.COMMAND, - text: "delete clones with [INPUTA] set to [INPUTB]", + text: Scratch.translate( + "delete clones with [INPUTA] set to [INPUTB]" + ), filter: [Scratch.TargetType.SPRITE], arguments: { INPUTA: { @@ -332,7 +350,7 @@ { opcode: "isClone", blockType: Scratch.BlockType.BOOLEAN, - text: "is clone?", + text: Scratch.translate("is clone?"), filter: [Scratch.TargetType.SPRITE], disableMonitor: true, extensions: ["colours_control"], @@ -343,13 +361,13 @@ { opcode: "cloneCount", blockType: Scratch.BlockType.REPORTER, - text: "clone count", + text: Scratch.translate("clone count"), extensions: ["colours_control"], }, { opcode: "spriteCloneCount", blockType: Scratch.BlockType.REPORTER, - text: "clone count of [INPUT]", + text: Scratch.translate("clone count of [INPUT]"), disableMonitor: true, arguments: { INPUT: { @@ -374,31 +392,31 @@ acceptReporters: false, items: [ { - text: "x position", + text: Scratch.translate("x position"), value: "x position", }, { - text: "y position", + text: Scratch.translate("y position"), value: "y position", }, { - text: "direction", + text: Scratch.translate("direction"), value: "direction", }, { - text: "costume #", + text: Scratch.translate("costume #"), value: "costume num", }, { - text: "costume name", + text: Scratch.translate("costume name"), value: "costume name", }, { - text: "size", + text: Scratch.translate("size"), value: "size", }, { - text: "volume", + text: Scratch.translate("volume"), value: "volume", }, ], @@ -630,7 +648,10 @@ const curTarget = targets[index].sprite; let display = curTarget.name; if (myself === curTarget.name) { - display = "myself"; + display = Scratch.translate({ + default: "myself", + description: "Item in a dropdown that refers to the current sprite", + }); } if (targets[index].isOriginal) { const jsonOBJ = { diff --git a/extensions/Lily/TempVariables.js b/extensions/Lily/TempVariables.js index a64d63d8d4..984a522bfa 100644 --- a/extensions/Lily/TempVariables.js +++ b/extensions/Lily/TempVariables.js @@ -10,7 +10,7 @@ getInfo() { return { id: "lmstempvars", - name: "Temporary Variables", + name: Scratch.translate("Temporary Variables"), color1: "#FF791A", color2: "#E15D00", menuIconURI: menuIconURI, @@ -18,7 +18,7 @@ { opcode: "setVariableTo", blockType: Scratch.BlockType.COMMAND, - text: "set variable [INPUTA] to [INPUTB]", + text: Scratch.translate("set variable [INPUTA] to [INPUTB]"), arguments: { INPUTA: { type: Scratch.ArgumentType.STRING, @@ -33,7 +33,7 @@ { opcode: "changeVariableBy", blockType: Scratch.BlockType.COMMAND, - text: "change variable [INPUTA] by [INPUTB]", + text: Scratch.translate("change variable [INPUTA] by [INPUTB]"), arguments: { INPUTA: { type: Scratch.ArgumentType.STRING, @@ -48,7 +48,7 @@ { opcode: "getVariable", blockType: Scratch.BlockType.REPORTER, - text: "variable [INPUT]", + text: Scratch.translate("variable [INPUT]"), disableMonitor: true, arguments: { INPUT: { @@ -63,7 +63,7 @@ { opcode: "deleteVariable", blockType: Scratch.BlockType.COMMAND, - text: "delete variable [INPUT]", + text: Scratch.translate("delete variable [INPUT]"), arguments: { INPUT: { type: Scratch.ArgumentType.STRING, @@ -74,12 +74,12 @@ { opcode: "deleteAllVariables", blockType: Scratch.BlockType.COMMAND, - text: "delete all variables", + text: Scratch.translate("delete all variables"), }, { opcode: "listVariables", blockType: Scratch.BlockType.REPORTER, - text: "list active variables", + text: Scratch.translate("list active variables"), disableMonitor: true, }, ], diff --git a/extensions/Lily/TempVariables2.js b/extensions/Lily/TempVariables2.js index 0d7b123b26..544f09bcf3 100644 --- a/extensions/Lily/TempVariables2.js +++ b/extensions/Lily/TempVariables2.js @@ -35,16 +35,16 @@ getInfo() { return { id: "lmsTempVars2", - name: "Temporary Variables", + name: Scratch.translate("Temporary Variables"), color1: "#FF791A", color2: "#E15D00", blocks: [ - label("Thread Variables", false), + label(Scratch.translate("Thread Variables"), false), { opcode: "setThreadVariable", blockType: Scratch.BlockType.COMMAND, - text: "set thread var [VAR] to [STRING]", + text: Scratch.translate("set thread var [VAR] to [STRING]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -59,7 +59,7 @@ { opcode: "changeThreadVariable", blockType: Scratch.BlockType.COMMAND, - text: "change thread var [VAR] by [NUM]", + text: Scratch.translate("change thread var [VAR] by [NUM]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -77,7 +77,7 @@ { opcode: "getThreadVariable", blockType: Scratch.BlockType.REPORTER, - text: "thread var [VAR]", + text: Scratch.translate("thread var [VAR]"), disableMonitor: true, allowDropAnywhere: true, arguments: { @@ -90,7 +90,7 @@ { opcode: "threadVariableExists", blockType: Scratch.BlockType.BOOLEAN, - text: "thread var [VAR] exists?", + text: Scratch.translate("thread var [VAR] exists?"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -104,7 +104,7 @@ { opcode: "forEachThreadVariable", blockType: Scratch.BlockType.LOOP, - text: "for [VAR] in [NUM]", + text: Scratch.translate("for [VAR] in [NUM]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -119,18 +119,18 @@ { opcode: "listThreadVariables", blockType: Scratch.BlockType.REPORTER, - text: "active thread variables", + text: Scratch.translate("active thread variables"), disableMonitor: true, }, "---", - label("Runtime Variables", false), + label(Scratch.translate("Runtime Variables"), false), { opcode: "setRuntimeVariable", blockType: Scratch.BlockType.COMMAND, - text: "set runtime var [VAR] to [STRING]", + text: Scratch.translate("set runtime var [VAR] to [STRING]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -145,7 +145,7 @@ { opcode: "changeRuntimeVariable", blockType: Scratch.BlockType.COMMAND, - text: "change runtime var [VAR] by [NUM]", + text: Scratch.translate("change runtime var [VAR] by [NUM]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -163,7 +163,7 @@ { opcode: "getRuntimeVariable", blockType: Scratch.BlockType.REPORTER, - text: "runtime var [VAR]", + text: Scratch.translate("runtime var [VAR]"), disableMonitor: true, allowDropAnywhere: true, arguments: { @@ -176,7 +176,7 @@ { opcode: "runtimeVariableExists", blockType: Scratch.BlockType.BOOLEAN, - text: "runtime var [VAR] exists?", + text: Scratch.translate("runtime var [VAR] exists?"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -190,7 +190,7 @@ { opcode: "deleteRuntimeVariable", blockType: Scratch.BlockType.COMMAND, - text: "delete runtime var [VAR]", + text: Scratch.translate("delete runtime var [VAR]"), arguments: { VAR: { type: Scratch.ArgumentType.STRING, @@ -201,12 +201,12 @@ { opcode: "deleteAllRuntimeVariables", blockType: Scratch.BlockType.COMMAND, - text: "delete all runtime variables", + text: Scratch.translate("delete all runtime variables"), }, { opcode: "listRuntimeVariables", blockType: Scratch.BlockType.REPORTER, - text: "active runtime variables", + text: Scratch.translate("active runtime variables"), }, ], };