mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
Allow localizing EV3 blocks (#1437)
* Add formatMessage calls to block text in EV3 extension * Make some EV3 l10n descriptions more descriptive
This commit is contained in:
parent
8d88058ae5
commit
f9814a5f88
1 changed files with 56 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
const ArgumentType = require('../../extension-support/argument-type');
|
const ArgumentType = require('../../extension-support/argument-type');
|
||||||
const BlockType = require('../../extension-support/block-type');
|
const BlockType = require('../../extension-support/block-type');
|
||||||
const Cast = require('../../util/cast');
|
const Cast = require('../../util/cast');
|
||||||
|
const formatMessage = require('format-message');
|
||||||
const uid = require('../../util/uid');
|
const uid = require('../../util/uid');
|
||||||
// const log = require('../../util/log');
|
// const log = require('../../util/log');
|
||||||
const Base64Util = require('../../util/base64-util');
|
const Base64Util = require('../../util/base64-util');
|
||||||
|
@ -828,7 +829,11 @@ class Scratch3Ev3Blocks {
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
opcode: 'motorTurnClockwise',
|
opcode: 'motorTurnClockwise',
|
||||||
text: 'motor [PORT] turn this way for [TIME] seconds',
|
text: formatMessage({
|
||||||
|
id: 'ev3.motorTurnClockwise',
|
||||||
|
default: 'motor [PORT] turn this way for [TIME] seconds',
|
||||||
|
description: 'turn a motor clockwise for some time'
|
||||||
|
}),
|
||||||
blockType: BlockType.COMMAND,
|
blockType: BlockType.COMMAND,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -844,7 +849,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'motorTurnCounterClockwise',
|
opcode: 'motorTurnCounterClockwise',
|
||||||
text: 'motor [PORT] turn that way for [TIME] seconds',
|
text: formatMessage({
|
||||||
|
id: 'ev3.motorTurnCounterClockwise',
|
||||||
|
default: 'motor [PORT] turn that way for [TIME] seconds',
|
||||||
|
description: 'turn a motor counter-clockwise for some time'
|
||||||
|
}),
|
||||||
blockType: BlockType.COMMAND,
|
blockType: BlockType.COMMAND,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -892,7 +901,11 @@ class Scratch3Ev3Blocks {
|
||||||
}, */
|
}, */
|
||||||
{
|
{
|
||||||
opcode: 'motorSetPower',
|
opcode: 'motorSetPower',
|
||||||
text: 'motor [PORT] set power [POWER] %',
|
text: formatMessage({
|
||||||
|
id: 'ev3.motorSetPower',
|
||||||
|
default: 'motor [PORT] set power [POWER] %',
|
||||||
|
description: 'set a motor\'s power to some value'
|
||||||
|
}),
|
||||||
blockType: BlockType.COMMAND,
|
blockType: BlockType.COMMAND,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -908,7 +921,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'getMotorPosition',
|
opcode: 'getMotorPosition',
|
||||||
text: 'motor [PORT] position',
|
text: formatMessage({
|
||||||
|
id: 'ev3.getMotorPosition',
|
||||||
|
default: 'motor [PORT] position',
|
||||||
|
description: 'get the measured degrees a motor has turned'
|
||||||
|
}),
|
||||||
blockType: BlockType.REPORTER,
|
blockType: BlockType.REPORTER,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -920,7 +937,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'whenButtonPressed',
|
opcode: 'whenButtonPressed',
|
||||||
text: 'when button [PORT] pressed',
|
text: formatMessage({
|
||||||
|
id: 'ev3.whenButtonPressed',
|
||||||
|
default: 'when button [PORT] pressed',
|
||||||
|
description: 'when a button connected to a port is pressed'
|
||||||
|
}),
|
||||||
blockType: BlockType.HAT,
|
blockType: BlockType.HAT,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -932,7 +953,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'whenDistanceLessThan',
|
opcode: 'whenDistanceLessThan',
|
||||||
text: 'when distance < [DISTANCE]',
|
text: formatMessage({
|
||||||
|
id: 'ev3.whenDistanceLessThan',
|
||||||
|
default: 'when distance < [DISTANCE]',
|
||||||
|
description: 'when the value measured by the distance sensor is less than some value'
|
||||||
|
}),
|
||||||
blockType: BlockType.HAT,
|
blockType: BlockType.HAT,
|
||||||
arguments: {
|
arguments: {
|
||||||
DISTANCE: {
|
DISTANCE: {
|
||||||
|
@ -943,7 +968,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'whenBrightnessLessThan',
|
opcode: 'whenBrightnessLessThan',
|
||||||
text: 'when brightness < [DISTANCE]',
|
text: formatMessage({
|
||||||
|
id: 'ev3.whenBrightnessLessThan',
|
||||||
|
default: 'when brightness < [DISTANCE]',
|
||||||
|
description: 'when value measured by brightness sensor is less than some value'
|
||||||
|
}),
|
||||||
blockType: BlockType.HAT,
|
blockType: BlockType.HAT,
|
||||||
arguments: {
|
arguments: {
|
||||||
DISTANCE: {
|
DISTANCE: {
|
||||||
|
@ -954,7 +983,11 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'buttonPressed',
|
opcode: 'buttonPressed',
|
||||||
text: 'button [PORT] pressed?',
|
text: formatMessage({
|
||||||
|
id: 'ev3.buttonPressed',
|
||||||
|
default: 'button [PORT] pressed?',
|
||||||
|
description: 'is a button on some port pressed?'
|
||||||
|
}),
|
||||||
blockType: BlockType.BOOLEAN,
|
blockType: BlockType.BOOLEAN,
|
||||||
arguments: {
|
arguments: {
|
||||||
PORT: {
|
PORT: {
|
||||||
|
@ -966,17 +999,29 @@ class Scratch3Ev3Blocks {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'getDistance',
|
opcode: 'getDistance',
|
||||||
text: 'distance',
|
text: formatMessage({
|
||||||
|
id: 'ev3.getDistance',
|
||||||
|
default: 'distance',
|
||||||
|
description: 'gets measured distance'
|
||||||
|
}),
|
||||||
blockType: BlockType.REPORTER
|
blockType: BlockType.REPORTER
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'getBrightness',
|
opcode: 'getBrightness',
|
||||||
text: 'brightness',
|
text: formatMessage({
|
||||||
|
id: 'ev3.getBrightness',
|
||||||
|
default: 'brightness',
|
||||||
|
description: 'gets measured brightness'
|
||||||
|
}),
|
||||||
blockType: BlockType.REPORTER
|
blockType: BlockType.REPORTER
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
opcode: 'beep',
|
opcode: 'beep',
|
||||||
text: 'beep note [NOTE] for [TIME] secs',
|
text: formatMessage({
|
||||||
|
id: 'ev3.beepNote',
|
||||||
|
default: 'beep note [NOTE] for [TIME] secs',
|
||||||
|
description: 'play some note on EV3 for some time'
|
||||||
|
}),
|
||||||
blockType: BlockType.COMMAND,
|
blockType: BlockType.COMMAND,
|
||||||
arguments: {
|
arguments: {
|
||||||
NOTE: {
|
NOTE: {
|
||||||
|
|
Loading…
Reference in a new issue