Created
December 15, 2021 05:14
-
-
Save Itz-fork/8f7683cd58a0694aca9de701af37027d to your computer and use it in GitHub Desktop.
Google Translate API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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