Skip to content

Commit

Permalink
Wrap js component into st.empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Jul 21, 2024
1 parent ff86d27 commit f3c8c70
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions package_build/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
import time
from pathlib import Path

import streamlit as st
from streamlit_javascript import st_javascript


def get_preferred_languages() -> list[str]:
while True:
languages = st_javascript("navigator.languages")
if languages:
return languages
with st.empty():
while True:
languages = st_javascript("window.navigator.languages")

time.sleep(0.1)
if languages:
return languages

time.sleep(0.1)


locale_dir = Path(__file__).parent / "locale"
Expand Down

0 comments on commit f3c8c70

Please sign in to comment.