Python 3 Google Cloud Translate API V2 Example to Translate Text in Various Languages in Command Line Full Project For Beginners

 

 

First of all you need to create the service account for connecting to the google cloud translate api and use it inside the python script.

 

 

 

 

 

pip install google-cloud-translate

 

 

 

app.py

 

 

import os

from google.cloud import translate_v2

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = r"googlekey.json"

translate_client = translate_v2.Client()

text = "जॉन विलियमसन लैथम न्यूजीलैंड के कप्तान हैं"

target = "en"

output = translate_client.translate(text,
target_language=target)

print(output)

 

 

python app.py

 

 

Leave a Reply