File size: 624 Bytes
68a8c29
6570b48
68a8c29
5a1315d
e4090f9
606d796
 
a397155
96e29d1
16fc4ca
606d796
a397155
16fc4ca
606d796
 
 
 
16fc4ca
b65ecd9
606d796
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import streamlit as st
import langcodes

# https://huggingface.co/blog/streamlit-spaces
langtext = st.text_area("language code", "en")



if langcodes.tag_is_valid('langtext'):
  st.write(f"'{langtext}' is a valid BCP-47 language code")  
  lang = langcodes.Language.get(langtext)
else:
  st.write(f"'{langtext}' is not a valid BCP-47 language code")  
  found = langcodes.find(langtext)
  lang = found
  st.write(f"langcodes found the following tag: {found}")


#st.write(f"langcodes found the following tag: {type(found)}") # a Language object
display = lang.display_name()
st.write(f"Display name for {lang}: {display}")