wop commited on
Commit
11ec9fd
1 Parent(s): af7845f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -50,20 +50,20 @@ def translate_text(text, target_lang):
50
  translation = translator.translate(text, dest=target_lang)
51
  return translation.text
52
 
53
- # Translate all text on the page
54
- def translate_page_content(language):
55
- elements = st.container._roots
56
- for element in elements:
57
- if hasattr(element, "body"):
58
- element.body = translate_text(element.body, get_language_code(language))
59
- st.experimental_rerun()
60
-
61
- # Translate the page content initially
62
- translate_page_content(default_language)
63
-
64
- # Listen for language changes and re-translate the page content
65
- if language_option != default_language:
66
- translate_page_content(language_option)
67
 
68
  client = Groq(
69
  api_key=os.environ['GROQ_API_KEY'],
 
50
  translation = translator.translate(text, dest=target_lang)
51
  return translation.text
52
 
53
+ # Function to translate text content
54
+ def translated_text(text, target_lang):
55
+ if target_lang == default_language:
56
+ return text
57
+ return translate_text(text, get_language_code(target_lang))
58
+
59
+ # Function to translate title
60
+ def translated_title(title, target_lang):
61
+ if target_lang == default_language:
62
+ return title
63
+ return translate_text(title, get_language_code(target_lang))
64
+
65
+ # Translate the title
66
+ st.title(translated_title("Chatbot", language_option))
67
 
68
  client = Groq(
69
  api_key=os.environ['GROQ_API_KEY'],