The "Translate" Extension
-
Introduction
You can use the “Translate” extension to translate some text to a target language.
Add the Translate Extension
You can click on the extension button at the bottom left, then select the Translate extension to add it:
There are 2 blocks in this extension:
The “language” Block
The “language” block tells us the local language used by the current user. When you switch the playground’s interface to another language, this block will report the updated language as well.
The “translate to” Block
This block takes 2 inputs:
- Any text that you want to translate from
- The target language that you can select from the dropdown
Since this is a reporter block, it will report a value directly, which is the translated text.
Translate to User’s Language
We can easily combine the 2 blocks above to achieve a useful feature: translating to the user’s language automatically.
For example, suppose your project will say “how are you?” to the user. You can put the “language” block into the language selector of the “translate” block, so that the sentence will be translated to the language used by the user.