langcode-search / app.py
cdleong's picture
Update app.py
b65ecd9
raw
history blame
550 Bytes
import streamlit as st
import langcodes
# https://huggingface.co/blog/streamlit-spaces
langtext = st.text_area("language code", "en")
found = langcodes.find(langtext)
display = found.display_name()
if langcodes.tag_is_valid('langtext'):
st.write(f"'{langtext}' is a valid BCP-47 language code")
else:
st.write(f"'{langtext}' is not a valid BCP-47 language code")
st.write(f"langcodes found the following tag: {found}")
#st.write(f"langcodes found the following tag: {type(found)}") # a Language object
st.write(f"Display name: {display}")