Skip to content

Instantly share code, notes, and snippets.

@Itz-fork
Created December 15, 2021 05:14
Show Gist options
  • Save Itz-fork/8f7683cd58a0694aca9de701af37027d to your computer and use it in GitHub Desktop.
Save Itz-fork/8f7683cd58a0694aca9de701af37027d to your computer and use it in GitHub Desktop.
Google Translate API example
import requests
def translate_text(text, dest):
req = requests.get(f"https://nexa-apis.herokuapp.com/tr?text={text}&dest_lang={dest}").json()
if req["status"] == "Ok":
return req["data"]
else:
return None
trans = translate_text("Hi!", "es")
if trans:
print(trans)
else:
print("Oops, Error Happend!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment