Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,25 @@ import langcodes
|
|
3 |
|
4 |
# https://huggingface.co/blog/streamlit-spaces
|
5 |
langtext = st.text_area("language code", "en")
|
|
|
|
|
6 |
|
7 |
|
8 |
|
9 |
if langcodes.tag_is_valid('langtext'):
|
10 |
st.write(f"'{langtext}' is a valid BCP-47 language code")
|
11 |
-
|
12 |
else:
|
13 |
st.write(f"'{langtext}' is not a valid BCP-47 language code")
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
#st.write(f"langcodes found the following tag: {type(found)}") # a Language object
|
20 |
display = lang.display_name()
|
|
|
3 |
|
4 |
# https://huggingface.co/blog/streamlit-spaces
|
5 |
langtext = st.text_area("language code", "en")
|
6 |
+
lang = langcodes.Language.get(langtext)
|
7 |
+
|
8 |
|
9 |
|
10 |
|
11 |
if langcodes.tag_is_valid('langtext'):
|
12 |
st.write(f"'{langtext}' is a valid BCP-47 language code")
|
13 |
+
|
14 |
else:
|
15 |
st.write(f"'{langtext}' is not a valid BCP-47 language code")
|
16 |
+
if lang.is_valid() == False:
|
17 |
+
try:
|
18 |
+
found = langcodes.find(langtext)
|
19 |
+
lang = found
|
20 |
+
st.write(f"langcodes found the following tag: {found}")
|
21 |
+
except LookupError as e:
|
22 |
+
st.write(f"Couldn't look up langtext, sorry: {e}")
|
23 |
+
lang = None
|
24 |
+
|
25 |
|
26 |
#st.write(f"langcodes found the following tag: {type(found)}") # a Language object
|
27 |
display = lang.display_name()
|