From 6a057b52732e52343d683f64629873862d8311f5 Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Sat, 11 May 2024 19:05:32 -0500 Subject: [PATCH] Translate some more extensions (#1463) --- extensions/CST1229/images.js | 2 +- extensions/bitwise.js | 38 +++++++++++--- extensions/text.js | 96 +++++++++++++++++++++++++++--------- extensions/utilities.js | 39 ++++++++++----- 4 files changed, 131 insertions(+), 44 deletions(-) diff --git a/extensions/CST1229/images.js b/extensions/CST1229/images.js index 43b33ccd0a..48cc2c16bf 100644 --- a/extensions/CST1229/images.js +++ b/extensions/CST1229/images.js @@ -28,7 +28,7 @@ getInfo() { return { id: "images", - name: "Images", + name: Scratch.translate("Images"), blocks: [ { opcode: "getImage", diff --git a/extensions/bitwise.js b/extensions/bitwise.js index e935d9b4f6..c079aac310 100644 --- a/extensions/bitwise.js +++ b/extensions/bitwise.js @@ -31,7 +31,7 @@ getInfo() { return { id: "Bitwise", - name: "Bitwise", + name: Scratch.translate("Bitwise"), color1: "#17cde6", @@ -42,7 +42,7 @@ { opcode: "isNumberBits", blockType: Scratch.BlockType.BOOLEAN, - text: "is [CENTRAL] binary?", + text: Scratch.translate("is [CENTRAL] binary?"), arguments: { CENTRAL: { type: Scratch.ArgumentType.NUMBER, @@ -54,7 +54,10 @@ { opcode: "toNumberBits", blockType: Scratch.BlockType.REPORTER, - text: "[CENTRAL] to binary", + text: Scratch.translate({ + default: "[CENTRAL] to binary", + description: "Blocks that converts number to binary", + }), arguments: { CENTRAL: { type: Scratch.ArgumentType.NUMBER, @@ -65,7 +68,10 @@ { opcode: "ofNumberBits", blockType: Scratch.BlockType.REPORTER, - text: "[CENTRAL] to number", + text: Scratch.translate({ + default: "[CENTRAL] to number", + description: "Block that converts binary to number", + }), arguments: { CENTRAL: { type: Scratch.ArgumentType.NUMBER, @@ -153,7 +159,11 @@ { opcode: "bitwiseAnd", blockType: Scratch.BlockType.REPORTER, - text: "[LEFT] and [RIGHT]", + text: Scratch.translate({ + default: "[LEFT] and [RIGHT]", + description: + "Block that does bitwise and (reports number with bits set only where both numbers had that bit)", + }), arguments: { LEFT: { type: Scratch.ArgumentType.NUMBER, @@ -168,7 +178,11 @@ { opcode: "bitwiseOr", blockType: Scratch.BlockType.REPORTER, - text: "[LEFT] or [RIGHT]", + text: Scratch.translate({ + default: "[LEFT] or [RIGHT]", + description: + "Block that does bitwise or (reports number with bits set where either number had that bit)", + }), arguments: { LEFT: { type: Scratch.ArgumentType.NUMBER, @@ -183,7 +197,11 @@ { opcode: "bitwiseXor", blockType: Scratch.BlockType.REPORTER, - text: "[LEFT] xor [RIGHT]", + text: Scratch.translate({ + default: "[LEFT] xor [RIGHT]", + description: + "Block that does bitwise eXclusive OR. (reports number with bits set only where exactly one of the numbers had that bit)", + }), arguments: { LEFT: { type: Scratch.ArgumentType.NUMBER, @@ -198,7 +216,11 @@ { opcode: "bitwiseNot", blockType: Scratch.BlockType.REPORTER, - text: "not [CENTRAL]", + text: Scratch.translate({ + default: "not [CENTRAL]", + description: + "Block that does a bitwise not. (flips all the bits in a number)", + }), arguments: { CENTRAL: { type: Scratch.ArgumentType.NUMBER, diff --git a/extensions/text.js b/extensions/text.js index 231b10beeb..e03c7705a9 100644 --- a/extensions/text.js +++ b/extensions/text.js @@ -24,23 +24,41 @@ _initCaseMenu() { return [ { - text: "lowercase", + text: Scratch.translate({ + default: "lowercase", + description: "If your language has lowercase, style it accordingly", + }), value: CaseParam.LOWERCASE, }, { - text: "UPPERCASE", + text: Scratch.translate({ + default: "UPPERCASE", + description: "If your language has uppercase, style it accordingly", + }), value: CaseParam.UPPERCASE, }, { - text: "Title Case", + text: Scratch.translate({ + default: "Title Case", + description: + "If your language has Title Case, style it accordingly. 'Abc' is title case and exactly title case but 'ABC' is only title case.", + }), value: CaseParam.TITLECASE, }, { - text: "Exactly Title Case", + text: Scratch.translate({ + default: "Exactly Title Case", + description: + "If your language has Title Case, style it accordingly. 'Abc' is title case and exactly title case but 'ABC' is only title case.", + }), value: CaseParam.EXACTTITLECASE, }, { - text: "MiXeD CaSe", + text: Scratch.translate({ + default: "MiXeD CaSe", + description: + "If your language has mixed case, style it accordingly", + }), value: CaseParam.MIXEDCASE, }, ]; @@ -48,15 +66,16 @@ getInfo() { return { - // id "text" could conflict with Scratch Lab's Animated Text - // for mods which implement it or if it ever comes out + // id "text" would conflict with Scratch Lab's Animated Text (lab/text.js) id: "strings", - name: "Text", + name: Scratch.translate("Text"), blocks: [ { opcode: "letters_of", blockType: Scratch.BlockType.REPORTER, - text: "letters [LETTER1] to [LETTER2] of [STRING]", + text: Scratch.translate( + "letters [LETTER1] to [LETTER2] of [STRING]" + ), arguments: { LETTER1: { type: Scratch.ArgumentType.NUMBER, @@ -75,7 +94,7 @@ { opcode: "split", blockType: Scratch.BlockType.REPORTER, - text: "item [ITEM] of [STRING] split by [SPLIT]", + text: Scratch.translate("item [ITEM] of [STRING] split by [SPLIT]"), arguments: { ITEM: { type: Scratch.ArgumentType.NUMBER, @@ -94,7 +113,11 @@ { opcode: "count", blockType: Scratch.BlockType.REPORTER, - text: "count [SUBSTRING] in [STRING]", + text: Scratch.translate({ + default: "count [SUBSTRING] in [STRING]", + description: + "Counts how many time [SUBSTRING] appears in [STRING]", + }), arguments: { SUBSTRING: { type: Scratch.ArgumentType.STRING, @@ -109,7 +132,10 @@ { opcode: "indexof", blockType: Scratch.BlockType.REPORTER, - text: "index of [SUBSTRING] in [STRING]", + text: Scratch.translate({ + default: "index of [SUBSTRING] in [STRING]", + description: "Reports where [SUBSTRING] appears in [STRING]", + }), arguments: { SUBSTRING: { type: Scratch.ArgumentType.STRING, @@ -127,7 +153,9 @@ { opcode: "replace", blockType: Scratch.BlockType.REPORTER, - text: "replace [SUBSTRING] in [STRING] with [REPLACE]", + text: Scratch.translate( + "replace [SUBSTRING] in [STRING] with [REPLACE]" + ), arguments: { SUBSTRING: { type: Scratch.ArgumentType.STRING, @@ -146,7 +174,7 @@ { opcode: "repeat", blockType: Scratch.BlockType.REPORTER, - text: "repeat [STRING] [REPEAT] times", + text: Scratch.translate("repeat [STRING] [REPEAT] times"), arguments: { STRING: { type: Scratch.ArgumentType.STRING, @@ -164,7 +192,7 @@ { opcode: "unicodeof", blockType: Scratch.BlockType.REPORTER, - text: "unicode of [STRING]", + text: Scratch.translate("unicode of [STRING]"), arguments: { STRING: { type: Scratch.ArgumentType.STRING, @@ -175,7 +203,7 @@ { opcode: "unicodefrom", blockType: Scratch.BlockType.REPORTER, - text: "unicode [NUM] as letter", + text: Scratch.translate("unicode [NUM] as letter"), arguments: { NUM: { type: Scratch.ArgumentType.NUMBER, @@ -188,7 +216,9 @@ { opcode: "replaceRegex", blockType: Scratch.BlockType.REPORTER, - text: "replace regex /[REGEX]/[FLAGS] in [STRING] with [REPLACE]", + text: Scratch.translate( + "replace regex /[REGEX]/[FLAGS] in [STRING] with [REPLACE]" + ), arguments: { REGEX: { type: Scratch.ArgumentType.STRING, @@ -211,7 +241,12 @@ { opcode: "matchRegex", blockType: Scratch.BlockType.REPORTER, - text: "item [ITEM] of [STRING] matched by regex /[REGEX]/[FLAGS]", + text: Scratch.translate({ + default: + "item [ITEM] of [STRING] matched by regex /[REGEX]/[FLAGS]", + description: + "/[REGEX]/ is supposed to match the syntax that some actual programming languages used for regular expressions.", + }), arguments: { ITEM: { type: Scratch.ArgumentType.NUMBER, @@ -234,7 +269,11 @@ { opcode: "countRegex", blockType: Scratch.BlockType.REPORTER, - text: "count regex /[REGEX]/[FLAGS] in [STRING]", + text: Scratch.translate({ + default: "count regex /[REGEX]/[FLAGS] in [STRING]", + description: + "/[REGEX]/ is supposed to match the syntax that some actual programming languages used for regular expressions.", + }), arguments: { STRING: { type: Scratch.ArgumentType.STRING, @@ -253,7 +292,11 @@ { opcode: "testRegex", blockType: Scratch.BlockType.BOOLEAN, - text: "[STRING] matches regex /[REGEX]/[FLAGS]?", + text: Scratch.translate({ + default: "[STRING] matches regex /[REGEX]/[FLAGS]?", + description: + "/[REGEX]/ is supposed to match the syntax that some actual programming languages used for regular expressions.", + }), arguments: { STRING: { type: Scratch.ArgumentType.STRING, @@ -275,7 +318,7 @@ { opcode: "identical", blockType: Scratch.BlockType.BOOLEAN, - text: "is [OPERAND1] identical to [OPERAND2]?", + text: Scratch.translate("is [OPERAND1] identical to [OPERAND2]?"), arguments: { OPERAND1: { type: Scratch.ArgumentType.STRING, @@ -293,7 +336,10 @@ { opcode: "isCase", blockType: Scratch.BlockType.BOOLEAN, - text: "is [STRING] [TEXTCASE]?", + text: Scratch.translate({ + default: "is [STRING] [TEXTCASE]?", + description: "Example block context: ", + }), arguments: { STRING: { type: Scratch.ArgumentType.STRING, @@ -309,7 +355,11 @@ { opcode: "toCase", blockType: Scratch.BlockType.REPORTER, - text: "convert [STRING] to [TEXTCASE]", + text: Scratch.translate({ + default: "convert [STRING] to [TEXTCASE]", + description: + "Example block context: (convert [HELLO] to [lowercase])", + }), arguments: { STRING: { type: Scratch.ArgumentType.STRING, diff --git a/extensions/utilities.js b/extensions/utilities.js index 33fecb766f..e1a6f31c3e 100644 --- a/extensions/utilities.js +++ b/extensions/utilities.js @@ -42,7 +42,7 @@ getInfo() { return { id: "utilities", - name: "Utilities", + name: Scratch.translate("Utilities"), color1: "#8BC34A", color2: "#7CB342", @@ -56,7 +56,7 @@ blockType: Scratch.BlockType.BOOLEAN, - text: "is [A] exactly [B]?", + text: Scratch.translate("is [A] exactly [B]?"), arguments: { A: { type: Scratch.ArgumentType.STRING, @@ -103,13 +103,19 @@ { opcode: "trueBlock", blockType: Scratch.BlockType.BOOLEAN, - text: "true", + text: Scratch.translate({ + default: "true", + description: "Block that returns true", + }), disableMonitor: true, }, { opcode: "falseBlock", blockType: Scratch.BlockType.BOOLEAN, - text: "false", + text: Scratch.translate({ + default: "false", + description: "Block that returns false", + }), disableMonitor: true, }, { @@ -130,14 +136,17 @@ { opcode: "pi", blockType: Scratch.BlockType.REPORTER, - text: "pi", + text: Scratch.translate({ + default: "pi", + description: "Block that returns 3.1415...", + }), }, { opcode: "ternaryOperator", blockType: Scratch.BlockType.REPORTER, - text: "if [A] then [B] else [C]", + text: Scratch.translate("if [A] then [B] else [C]"), arguments: { A: { type: Scratch.ArgumentType.BOOLEAN, @@ -158,7 +167,7 @@ blockType: Scratch.BlockType.REPORTER, - text: "letters [START] to [END] of [STRING]", + text: Scratch.translate("letters [START] to [END] of [STRING]"), arguments: { START: { type: Scratch.ArgumentType.NUMBER, @@ -179,7 +188,7 @@ blockType: Scratch.BlockType.REPORTER, - text: "clamp [INPUT] between [MIN] and [MAX]", + text: Scratch.translate("clamp [INPUT] between [MIN] and [MAX]"), arguments: { INPUT: { type: Scratch.ArgumentType.NUMBER, @@ -198,14 +207,14 @@ { opcode: "currentMillisecond", blockType: Scratch.BlockType.REPORTER, - text: "current millisecond", + text: Scratch.translate("current millisecond"), }, { opcode: "fetchFrom", blockType: Scratch.BlockType.REPORTER, - text: "get content from [URL]", + text: Scratch.translate("get content from [URL]"), arguments: { URL: { type: Scratch.ArgumentType.STRING, @@ -218,7 +227,11 @@ blockType: Scratch.BlockType.REPORTER, - text: "[PATH] of [JSON_STRING]", + text: Scratch.translate({ + default: "[PATH] of [JSON_STRING]", + description: + 'PATH is a string like "fruit/apples" and JSON_STRING is an object like {"fruit":{"apples":3}}. 3 would be reported in this example.', + }), arguments: { PATH: { type: Scratch.ArgumentType.STRING, @@ -256,7 +269,9 @@ blockType: Scratch.BlockType.REPORTER, - text: "replace [STRING] using the rule [REGEX] with [NEWSTRING]", + text: Scratch.translate( + "replace [STRING] using the rule [REGEX] with [NEWSTRING]" + ), arguments: { STRING: { type: Scratch.ArgumentType.STRING,