Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (July 2021)
Reason: Nothing but a list of variables and a single scratchblocks tag

A Translator is a project which can change words into different languages using the Translate Extension. This tutorial will show how to make a translator.

Preparation

One sprite will be needed:

  • Button

Two variables will be needed:

  • (to language)
  • (word)

Two broadcasts will be needed:

  • broadcast (original v)
  • broadcast (to what v)

Programming The Sprites

Add the following code to the button

when green flag clicked
broadcast (original v)

when I receive [original v]
say [Click this button to translate.]
wait until <<touching (mouse-pointer v)> and <mouse down?>> //This waits until the button is clicked
say []//This is so it stops saying "Click this button to translate"
ask [What shall be translated? Please only enter real words or the translator will not work.] and wait
set [word v] to (answer)
broadcast (to what v)

when I receive [to what v]
ask [To what language?] and wait
set [to language v] to (answer)
if <(translate (word) to (to language)) = (word)> then //This is to make sure a supported language is entered
say [Please enter a supported language.] for (2) seconds
broadcast (to what v)
else
say (translate (word) to (to language)) 
wait until <<touching (mouse-pointer v)> and <mouse down?>>
say []
broadcast (original v)

Your translator is now ready!


Cookies help us deliver our services. By using our services, you agree to our use of cookies.