AamerAkhter's picture
Update app.py
3c0c41f verified
Raw
History Blame Contribute Delete
1.05 kB
import streamlit as st
from deep_translator import GoogleTranslator
# 🌟 Give our toy box a giant title!
st.title("🌟 The Magic Streamlit Language Box 🌟")
st.write("Type words, pick a direction, and watch the magic parrot do the work!")
# ✍️ The big box to type words
my_words = st.text_area("Type your words here... ✍️")
# πŸ”˜ The buttons to pick the direction
direction = st.radio("Which way?", ["English to Urdu", "Urdu to English"])
# πŸš€ The magic button to make the parrot fly!
if st.button("Translate! ✨"):
# Check if the text box is empty first
if my_words == "":
st.warning("Oops! You forgot to type some words! πŸ™ˆ")
else:
if direction == "English to Urdu":
# 🦜 Parrot flies to Urdu
answer = GoogleTranslator(source='en', target='ur').translate(my_words)
st.success(answer)
else:
# 🦜 Parrot flies to English
answer = GoogleTranslator(source='ur', target='en').translate(my_words)
st.success(answer)