From ed78231fe99d2a7b659816cdd68223838a7c33f8 Mon Sep 17 00:00:00 2001
From: picklesrus <picklesrus@users.noreply.github.com>
Date: Sun, 15 Jul 2018 13:34:24 -0500
Subject: [PATCH] Turn speech block text into i18n messages. (#1224)

* Turn speech block text into i18n messages.

* Update message descriptions and other code review comments.

* fix typo

* Add bit about not translating Google to message description.

* Change default when I hear text
---
 src/extensions/scratch3_speech/index.js | 33 +++++++++++++++++++++----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/extensions/scratch3_speech/index.js b/src/extensions/scratch3_speech/index.js
index e4ce73b24..e4f5c362a 100644
--- a/src/extensions/scratch3_speech/index.js
+++ b/src/extensions/scratch3_speech/index.js
@@ -1,6 +1,7 @@
 const ArgumentType = require('../../extension-support/argument-type');
 const Cast = require('../../util/cast');
 const BlockType = require('../../extension-support/block-type');
+const formatMessage = require('format-message');
 const log = require('../../util/log');
 const DiffMatchPatch = require('diff-match-patch');
 
@@ -684,29 +685,51 @@ class Scratch3SpeechBlocks {
     getInfo () {
         return {
             id: 'speech',
-            name: 'Google Speech',
+            name: formatMessage({
+                id: 'speech.extensionName',
+                default: 'Google Speech',
+                description: 'Name of extension that adds speech recognition blocks. Do Not translate Google.'
+            }),
             menuIconURI: menuIconURI,
             blockIconURI: iconURI,
             blocks: [
                 {
                     opcode: 'listenAndWait',
-                    text: 'Listen and Wait',
+                    text: formatMessage({
+                        id: 'speech.listenAndWait',
+                        default: 'listen and wait',
+                        // eslint-disable-next-line max-len
+                        description: 'Start listening to the microphone and wait for a result from the speech recognition system.'
+                    }),
                     blockType: BlockType.COMMAND
                 },
                 {
                     opcode: 'whenIHearHat',
-                    text: 'When I hear [PHRASE]',
+                    text: formatMessage({
+                        id: 'speech.whenIHear',
+                        default: 'when I hear [PHRASE]',
+                        // eslint-disable-next-line max-len
+                        description: 'Event that triggers when the text entered on the block is recognized by the speech recognition system.'
+                    }),
                     blockType: BlockType.HAT,
                     arguments: {
                         PHRASE: {
                             type: ArgumentType.STRING,
-                            defaultValue: 'cat'
+                            defaultValue: formatMessage({
+                                id: 'speech.defaultWhenIHearValue',
+                                default: 'let\'s go',
+                                description: 'The default phrase/word that, when heard, triggers the event.'
+                            })
                         }
                     }
                 },
                 {
                     opcode: 'getSpeech',
-                    text: 'speech',
+                    text: formatMessage({
+                        id: 'speech.speechReporter',
+                        default: 'speech',
+                        description: 'Get the text of spoken words transcribed by the speech recognition system.'
+                    }),
                     blockType: BlockType.REPORTER
                 }
             ]