wenjiao commited on
Commit
672d639
·
1 Parent(s): 858b8f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -6,17 +6,19 @@ md = "test"
6
  CN_md = "测试"
7
 
8
  def update_language(value):
9
- global language
10
- language = value
11
-
 
 
12
  with gr.Blocks() as demo:
13
- if (language == "zh-CN"):
14
  gr.markdown(CN_md)
15
- else:
16
  gr.markdown(md)
17
 
18
  dt = gr.Textbox(label="Current time")
19
- dt.change(update_language)
20
 
21
  demo.load(None, inputs=None, outputs=dt, _js="() => navigator.language")
22
 
 
6
  CN_md = "测试"
7
 
8
  def update_language(value):
9
+ if value == "zh-CN":
10
+ return [gr.update(visible=False), gr.update(visible=True)]
11
+ else:
12
+ return [gr.update(visible=False), gr.update(visible=True)]
13
+
14
  with gr.Blocks() as demo:
15
+ with row() as zh:
16
  gr.markdown(CN_md)
17
+ with row() as eng:
18
  gr.markdown(md)
19
 
20
  dt = gr.Textbox(label="Current time")
21
+ dt.change(update_language, input=dt, output=[eng, zh])
22
 
23
  demo.load(None, inputs=None, outputs=dt, _js="() => navigator.language")
24