Spaces:
Running
Running
admin
commited on
Commit
·
1e5e427
1
Parent(s):
00a5428
add trans
Browse files
app.py
CHANGED
@@ -1,6 +1,20 @@
|
|
|
|
1 |
import subprocess
|
2 |
import gradio as gr
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def infer(command):
|
6 |
status = "Success"
|
@@ -22,12 +36,12 @@ def infer(command):
|
|
22 |
if __name__ == "__main__":
|
23 |
gr.Interface(
|
24 |
fn=infer,
|
25 |
-
inputs=gr.Textbox(label="Linux
|
26 |
outputs=[
|
27 |
-
gr.Textbox(label="
|
28 |
-
gr.TextArea(label="
|
29 |
],
|
30 |
-
title="Linux
|
31 |
-
description="
|
32 |
flagging_mode="never",
|
33 |
).launch(ssr_mode=False)
|
|
|
1 |
+
import os
|
2 |
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
+
EN_US = os.getenv("LANG") != "zh_CN.UTF-8"
|
6 |
+
ZH2EN = {
|
7 |
+
"输入 Linux 命令": "Linux Command",
|
8 |
+
"状态栏": "Status",
|
9 |
+
"执行结果": "Command Output",
|
10 |
+
"Linux 命令执行测试工具": "Linux Command Executor",
|
11 |
+
"输入一个 Linux 命令, 点击提交查看其执行结果": "Enter a Linux command and click submit to see the output.",
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
def _L(zh_txt: str):
|
16 |
+
return ZH2EN[zh_txt] if EN_US else zh_txt
|
17 |
+
|
18 |
|
19 |
def infer(command):
|
20 |
status = "Success"
|
|
|
36 |
if __name__ == "__main__":
|
37 |
gr.Interface(
|
38 |
fn=infer,
|
39 |
+
inputs=gr.Textbox(label=_L("输入 Linux 命令"), value="ls"),
|
40 |
outputs=[
|
41 |
+
gr.Textbox(label=_L("状态栏"), show_copy_button=True),
|
42 |
+
gr.TextArea(label=_L("执行结果"), show_copy_button=True),
|
43 |
],
|
44 |
+
title=_L("Linux 命令执行测试工具"),
|
45 |
+
description=_L("输入一个 Linux 命令, 点击提交查看其执行结果"),
|
46 |
flagging_mode="never",
|
47 |
).launch(ssr_mode=False)
|