Update app.py
Browse files
app.py
CHANGED
@@ -27,9 +27,6 @@ language_names = {
|
|
27 |
'Zulu': 'zu'
|
28 |
}
|
29 |
|
30 |
-
# Define a dictionary of reverse language codes to language names
|
31 |
-
reverse_language_names = {code: lang for lang, code in language_names.items()}
|
32 |
-
|
33 |
# Function to translate text
|
34 |
def translate_text(text, target_language_code):
|
35 |
try:
|
@@ -43,11 +40,14 @@ def translate_text(text, target_language_code):
|
|
43 |
except Exception as e:
|
44 |
return f"Translation failed: {str(e)}"
|
45 |
|
46 |
-
# Target language selection
|
47 |
st.subheader("Select the target language for translation:")
|
48 |
selected_target_language = st.selectbox("Select a target language:", list(language_names.keys()))
|
49 |
|
50 |
# Display the translated text as the user types
|
51 |
if user_text:
|
52 |
translated_text = translate_text(user_text, language_names[selected_target_language])
|
53 |
-
|
|
|
|
|
|
|
|
27 |
'Zulu': 'zu'
|
28 |
}
|
29 |
|
|
|
|
|
|
|
30 |
# Function to translate text
|
31 |
def translate_text(text, target_language_code):
|
32 |
try:
|
|
|
40 |
except Exception as e:
|
41 |
return f"Translation failed: {str(e)}"
|
42 |
|
43 |
+
# Target language selection
|
44 |
st.subheader("Select the target language for translation:")
|
45 |
selected_target_language = st.selectbox("Select a target language:", list(language_names.keys()))
|
46 |
|
47 |
# Display the translated text as the user types
|
48 |
if user_text:
|
49 |
translated_text = translate_text(user_text, language_names[selected_target_language])
|
50 |
+
|
51 |
+
# Apply advanced CSS for better display in a bordered box
|
52 |
+
styled_text = f'<div style="border: 2px solid #0072B5; padding: 10px; background-color: #E5E5E5; border-radius: 5px; color: black;">{translated_text}</div>'
|
53 |
+
st.markdown(styled_text, unsafe_allow_html=True)
|