hmb HF Staff commited on
Commit
3042d91
·
verified ·
1 Parent(s): 0e13246

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Create an i18n instance with translations for different languages
4
+ i18n = gr.i18n(
5
+ en={"name_label": "Your Name", "submit_button": "Greet", "john_doe": "John English"},
6
+ es={"name_label": "Tu Nombre", "submit_button": "Saludar", "john_doe": "John Spanish"},
7
+ fr={"name_label": "Votre Nom", "submit_button": "Saluer", "john_doe": "John French"},
8
+ de={"name_label": "Dein Name", "submit_button": "Grüßen", "john_doe": "John German"},
9
+ )
10
+
11
+ with gr.Blocks() as demo:
12
+ with gr.Row():
13
+ name_input = gr.Textbox(label=i18n("name_label"), value=i18n("john_doe"))
14
+
15
+ with gr.Row():
16
+ greet_btn = gr.Button(i18n("submit_button"))
17
+ goodbye_btn = gr.Button("Cancel")
18
+
19
+ gr.Markdown("""
20
+ This demo shows Gradio's internationalization (i18n) functionality.
21
+ The interface automatically displays text in the user's browser language
22
+ (if available in our translations), or falls back to English.
23
+ """)
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch(i18n=i18n)