import streamlit as st from googletrans import Translator # Function to translate text def translate_text(text, src_lang, dest_lang): translator = Translator() translated_text = translator.translate(text, src=src_lang, dest=dest_lang) return translated_text.text def main(): # Setting page title and favicon st.set_page_config( page_title="Translator", page_icon="🌐", layout="wide", initial_sidebar_state="collapsed" ) # Title and logo st.title("Translator") st.image("logo.png", width=200) # Add your logo image here # Developer name st.sidebar.markdown("---") st.sidebar.subheader("Developed by:") st.sidebar.write("Adil") st.sidebar.markdown("Founder of DataScience-ProF") # Translation direction translation_direction = st.radio("Select Translation Direction:", ("Telugu to English", "English to Telugu")) # Input text area if translation_direction == "Telugu to English": input_label = "Enter Telugu text:" src_lang = 'te' dest_lang = 'en' else: input_label = "Enter English text:" src_lang = 'en' dest_lang = 'te' text = st.text_area(input_label, height=200) # Translate button if st.button("Translate"): # Perform translation if text.strip() != "": translated_text = translate_text(text, src_lang, dest_lang) st.success("Translated Text:") st.write(translated_text) else: st.warning("Please enter some text to translate.") if __name__ == "__main__": main()