Keldos commited on
Commit
fe3346f
1 Parent(s): 76699a6

feat: 更新窗口加入本地化

Browse files
ChuanhuChatbot.py CHANGED
@@ -38,7 +38,14 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
38
  status_display = gr.Markdown(get_geoip(), elem_id="status_display")
39
  with gr.Row(elem_id="float_display"):
40
  user_info = gr.Markdown(value="getting user info...", elem_id="user_info")
41
- update_info = gr.HTML(get_html("update.html").format(current_version=repo_html(),version_time=version_time()), visible=check_update)
 
 
 
 
 
 
 
42
 
43
  with gr.Row().style(equal_height=True):
44
  with gr.Column(scale=5):
 
38
  status_display = gr.Markdown(get_geoip(), elem_id="status_display")
39
  with gr.Row(elem_id="float_display"):
40
  user_info = gr.Markdown(value="getting user info...", elem_id="user_info")
41
+ update_info = gr.HTML(get_html("update.html").format(
42
+ current_version=repo_html(),
43
+ version_time=version_time(),
44
+ cancel_btn=i18n("取消"),
45
+ update_btn=i18n("更新"),
46
+ seenew_btn=i18n("详情"),
47
+ ok_btn=i18n("好"),
48
+ ), visible=check_update)
49
 
50
  with gr.Row().style(equal_height=True):
51
  with gr.Column(scale=5):
assets/custom.css CHANGED
@@ -88,9 +88,8 @@ footer {
88
  }
89
  .btn-update-group {
90
  display: flex;
91
- justify-content: space-between;
92
  align-items: center;
93
- max-width: 72%;
94
  width: 100%;
95
  padding-top: 10px;
96
  }
 
88
  }
89
  .btn-update-group {
90
  display: flex;
91
+ justify-content: space-evenly;
92
  align-items: center;
 
93
  width: 100%;
94
  padding-top: 10px;
95
  }
assets/custom.js CHANGED
@@ -53,6 +53,12 @@ var deleteConfirm_i18n_suff = {
53
  var deleteConfirm_msg_pref = "Are you sure you want to delete ";
54
  var deleteConfirm_msg_suff = " ?";
55
 
 
 
 
 
 
 
56
  // gradio 页面加载好了么??? 我能动你的元素了么??
57
  function gradioLoaded(mutations) {
58
  for (var i = 0; i < mutations.length; i++) {
@@ -586,7 +592,8 @@ function noUpdate() {
586
  const releaseNoteWrap = document.getElementById('release-note-wrap');
587
  const gotoUpdateBtn = document.getElementById('goto-update-btn');
588
  const closeUpdateBtn = document.getElementById('close-update-btn');
589
- versionInfoElement.textContent = 'You are using the latest version!';
 
590
  releaseNoteWrap.style.setProperty('display', 'none');
591
  gotoUpdateBtn.classList.add('hideK');
592
  closeUpdateBtn.classList.remove('hideK');
 
53
  var deleteConfirm_msg_pref = "Are you sure you want to delete ";
54
  var deleteConfirm_msg_suff = " ?";
55
 
56
+ var usingLatest_i18n = {
57
+ 'zh': "您使用的就是最新版!",
58
+ 'en': "You are using the latest version!",
59
+ 'ja': "最新バージョンを使用しています!",
60
+ };
61
+
62
  // gradio 页面加载好了么??? 我能动你的元素了么??
63
  function gradioLoaded(mutations) {
64
  for (var i = 0; i < mutations.length; i++) {
 
592
  const releaseNoteWrap = document.getElementById('release-note-wrap');
593
  const gotoUpdateBtn = document.getElementById('goto-update-btn');
594
  const closeUpdateBtn = document.getElementById('close-update-btn');
595
+
596
+ versionInfoElement.textContent = usingLatest_i18n.hasOwnProperty(language) ? usingLatest_i18n[language] : usingLatest_i18n['en'];
597
  releaseNoteWrap.style.setProperty('display', 'none');
598
  gotoUpdateBtn.classList.add('hideK');
599
  closeUpdateBtn.classList.remove('hideK');
assets/html/update.html CHANGED
@@ -14,12 +14,12 @@
14
  </div>
15
  </div>
16
  <div id="goto-update-btn" class="btn-update-group">
17
- <button class="btn-update lg secondary svelte-1ipelgc" id="cancel-button" onclick="cancelUpdate()">Cancel</button>
18
- <button class="btn-update lg primary svelte-1ipelgc" id="update-button" onclick="getUpdate()">Update</button>
19
  </div>
20
  <div id="close-update-btn" class="btn-update-group hideK">
21
- <button class="btn-update lg secondary svelte-1ipelgc" id="update-button" onclick="getUpdate()">What's new</button>
22
- <button class="btn-update lg primary svelte-1ipelgc" id="cancel-button" onclick="cancelUpdate()">OK</button>
23
  </div>
24
  </div>
25
  </div>
 
14
  </div>
15
  </div>
16
  <div id="goto-update-btn" class="btn-update-group">
17
+ <button class="btn-update lg secondary svelte-1ipelgc" id="cancel-button" onclick="cancelUpdate()">{cancel_btn}</button>
18
+ <button class="btn-update lg primary svelte-1ipelgc" id="update-button" onclick="getUpdate()">{update_btn}</button>
19
  </div>
20
  <div id="close-update-btn" class="btn-update-group hideK">
21
+ <button class="btn-update lg secondary svelte-1ipelgc" id="update-button" onclick="getUpdate()">{seenew_btn}</button>
22
+ <button class="btn-update lg primary svelte-1ipelgc" id="cancel-button" onclick="cancelUpdate()">{ok_btn}</button>
23
  </div>
24
  </div>
25
  </div>
locale/en_US.json CHANGED
@@ -44,6 +44,11 @@
44
  "代理地址(示例:http://127.0.0.1:10809)": "Proxy address (example: http://127.0.0.1:10809)",
45
  "🔄 设置代理地址": "🔄 Set Proxy Address",
46
  "🔙 恢复默认设置": "🔙 Restore Default Settings",
 
 
 
 
 
47
  "川虎Chat 🚀": "Chuanhu Chat 🚀",
48
  "开始实时传输回答……": "Start streaming output...",
49
  "Token 计数: ": "Token Count: ",
 
44
  "代理地址(示例:http://127.0.0.1:10809)": "Proxy address (example: http://127.0.0.1:10809)",
45
  "🔄 设置代理地址": "🔄 Set Proxy Address",
46
  "🔙 恢复默认设置": "🔙 Restore Default Settings",
47
+ "🔄 检查更新...": "🔄 Check for Update...",
48
+ "取消": "Cancel",
49
+ "更新": "Update",
50
+ "详情": "Details",
51
+ "好": "OK",
52
  "川虎Chat 🚀": "Chuanhu Chat 🚀",
53
  "开始实时传输回答……": "Start streaming output...",
54
  "Token 计数: ": "Token Count: ",
locale/ja_JP.json CHANGED
@@ -44,6 +44,11 @@
44
  "代理地址(示例:http://127.0.0.1:10809)": "プロキシアドレス(例:http://127.0.0.1:10809)",
45
  "🔄 设置代理地址": "🔄 プロキシアドレスを設定",
46
  "🔙 恢复默认设置": "🔙 デフォルト設定に戻す",
 
 
 
 
 
47
  "川虎Chat 🚀": "川虎Chat 🚀",
48
  "开始实时传输回答……": "ストリーム出力開始……",
49
  "Token 计数: ": "Token数: ",
 
44
  "代理地址(示例:http://127.0.0.1:10809)": "プロキシアドレス(例:http://127.0.0.1:10809)",
45
  "🔄 设置代理地址": "🔄 プロキシアドレスを設定",
46
  "🔙 恢复默认设置": "🔙 デフォルト設定に戻す",
47
+ "🔄 检查更新...": "🔄 アップデートをチェック...",
48
+ "取消": "キャンセル",
49
+ "更新": "アップデート",
50
+ "详情": "詳細",
51
+ "好": "はい",
52
  "川虎Chat 🚀": "川虎Chat 🚀",
53
  "开始实时传输回答……": "ストリーム出力開始……",
54
  "Token 计数: ": "Token数: ",