Using a translator to translate words in a list

If in my code I display a word, "red" in English from a list when a button is clicked, how would I use a translator to display the word "red" translated into spanish, and how could I use a loop in my procedure for it to go through the rest of the colors (orange, yellow, green, etc...) once those buttons are clicked as well. this is the code I have now, that is currently not translating. Thank you for the help!

I'm afraid that the translator api is too slow to use in a fast loop. You have to translate the next word after translating the previous one.

would there be a way to loop the whole process? so that it just went through everything multiple times as a serperate button was pressed or no

Yes, these blocks are draggable:


blocks - 2023-04-23T193515.740


This should work. I can't check because I get responseCode "404", and translation "Yandex returnederror code 501" from Yandex.

Does the translator with ApiKey from Mit work for you?

If you know all the words to translate ahead of time, you could avoid run time translation entirely using a lookup table or the advanced replace from dictionary block.

you got an error 505 because you did not provide the correct languageToTranslateTo code. The code for English to Spanish must be en-es

@Bella if you want the app to say the translation in the correct language, you also want to set the TTS language.

speak text in Spanish

Yes, that's it :smiley:

It worked:


blocks - 2023-04-23T193515.740


Yes, :astonished: if you set the Clock.TimeInterval to 2000 ms or so.

thank you all for the help!

Does anyone know how to properly use the loop in my code to get the text to speech translated version to repeat slowly? Do i need to use a timer? How would i do that? Because as of now, it just repeats the word very quickly. I would like for there to be a pause.

What about yesterday's solutions to which we devoted our time?

Slow Loop:

Solution1:

Solution2:

What's wrong with these solutions?

Use solution 2, and set the timer to e.g. 4000.

Yes, it's a slow loop.

Oh yes I completely forgot I asked a similar question, thank you for the redirection

I now merged the 2 threads...
Taifun

2 Likes

It is dangerous to use the same variable ('index') as an index for two separate lists, unless those lists are the same length and matched item for item.