Google Translation Extension

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

component_event

Description: Event raised when translated text got.
Params:

  1. translatedText: String value of source text in the target language.

TranslateText

component_method

Description: Translate your text to the target language from the source language.
Params:

  1. text: String value of source text that you want to translate.
  2. sourceLang: Source language code given by Google.
  3. targetLang: Target language code given by Google,

language codes

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


  1. 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.
  2. 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

10 Likes

You can request 5000 times in a day with your free Google account, for more information you can see this page...

Quotas for Google Services  |  Apps Script  |  Google Developers

Nice extension...

But I think you should rename APIKey to ApiKey, since API is one term.

The YandexTranslate component uses the ApiKey naming convention.

But still, great extension.

3 Likes

https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=en&tl=hi&dt=t&q=you+can+use+this

you can use this also to translate

1 Like

(added to FAQ)

1 Like