File size: 1,629 Bytes
e7b8a50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()