Google Translate Extension
Hello everyone,
I hope you all are doing well, before some time I have seen someone has requested for translation function in his/her app, so I have created a simple GoogleTranslate extension with the help of Google App Script.
Blocks
GotTranslatedText
Description: Event raised when translated text got.
Params:
- translatedText: String value of source text in the target language.
TranslateText
Description: Translate your text to the target language from the source language.
Params:
- text: String value of source text that you want to translate.
- sourceLang: Source language code given by Google.
- targetLang: Target language code given by Google,
APIKey
Description: Set your own deployment key after deployment in case if you don't want to deploy your own web app use this key
KEY
AKfycbwUHkkdLJU5eIgLxErRCxtDpbs4_qz3P48RXbWstMYvA8ClmU56qT7pdcBpQ_S_7FX1
Google App Script
Step: 1
Go to Google App Script and create a new project. link
Step: 2
Copy the given script and paste it into your project.
Click on the save button and deploy it.
function doGet(e) {
let sourceLang = e.parameters.sl;
let destLang = e.parameters.dl;
let text = e.parameters.text;
let transletedText = LanguageApp.translate(text.toString(), sourceLang.toString(), destLang.toString());
return ContentService.createTextOutput(transletedText).setMimeType(ContentService.MimeType.JSON);
}
Step : 3
Set the deployment configuration shown in the given picture, now hit on the deploy button and copy-paste it into App Inventor.
Note
- The default deployment key and the key which you see in the picture is only for testing, I am not sure it will help you in the future or not, so I recommend you deploy your own script as a web app.
- If you find any kind of problem then, please write in this thread.
Download Link
GoogleTranslate (2).aix (6.5 KB)
Thanks and Regards
Preet P. Vadaliya