gradio-i18n / app.py
hoveyc's picture
Update example
f1597cc
raw
history blame
743 Bytes
import gradio as gr
from gradio_i18n import Translate
from gradio_i18n import gettext as _
def greet(name, lang):
return f"Hello {name} in {lang}!"
with gr.Blocks() as demo:
gr.Markdown(value="> Check out [Repository](https://github.com/hoveychen/gradio-i18n) for more examples")
lang = gr.Radio(choices=[("English", "en"), ("中文", "zh")], label=_("Language"))
with Translate("translation.yaml", lang, placeholder_langs=["en", "zh"]):
name = gr.Textbox(label=_("Name"), placeholder=_("Input your name here."))
output = gr.Textbox(label=_("Greeting"))
submit_btn = gr.Button(value=_("Submit"))
submit_btn.click(greet, inputs=[name, lang], outputs=output)
demo.launch(server_name="0.0.0.0")