Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
b2d64ee
1
Parent(s):
8ce3aed
feat: 删除对话记录的确认增加本地化
Browse files注意,此处根据浏览器环境语言进行本地化,与config设置的语言无关
- ChuanhuChatbot.py +1 -1
- assets/custom.js +18 -2
ChuanhuChatbot.py
CHANGED
|
@@ -435,7 +435,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
| 435 |
historyRefreshBtn.click(**refresh_history_args)
|
| 436 |
historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown, chatbot], _js='''function showConfirmationDialog(a, b, c) {
|
| 437 |
if (b != "") {
|
| 438 |
-
var result = confirm(
|
| 439 |
if (result) {
|
| 440 |
return [a, b, c];
|
| 441 |
}
|
|
|
|
| 435 |
historyRefreshBtn.click(**refresh_history_args)
|
| 436 |
historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown, chatbot], _js='''function showConfirmationDialog(a, b, c) {
|
| 437 |
if (b != "") {
|
| 438 |
+
var result = confirm(deleteConfirm_msg_pref + b + deleteConfirm_msg_suff);
|
| 439 |
if (result) {
|
| 440 |
return [a, b, c];
|
| 441 |
}
|
assets/custom.js
CHANGED
|
@@ -37,6 +37,19 @@ var forView_i18n = {
|
|
| 37 |
'es': "Solo para visualización",
|
| 38 |
};
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
// gradio 页面加载好了么??? 我能动你的元素了么??
|
| 41 |
function gradioLoaded(mutations) {
|
| 42 |
for (var i = 0; i < mutations.length; i++) {
|
|
@@ -85,13 +98,16 @@ function gradioLoaded(mutations) {
|
|
| 85 |
}
|
| 86 |
|
| 87 |
function webLocale() {
|
| 88 |
-
console.log("webLocale", language);
|
| 89 |
if (forView_i18n.hasOwnProperty(language)) {
|
| 90 |
var forView = forView_i18n[language];
|
| 91 |
var forViewStyle = document.createElement('style');
|
| 92 |
forViewStyle.innerHTML = '.wrap>.history-message>:last-child::after { content: "' + forView + '"!important; }';
|
| 93 |
document.head.appendChild(forViewStyle);
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
}
|
| 97 |
|
|
|
|
| 37 |
'es': "Solo para visualización",
|
| 38 |
};
|
| 39 |
|
| 40 |
+
var deleteConfirm_i18n_pref = {
|
| 41 |
+
'zh': "你真的要删除 ",
|
| 42 |
+
'en': "Are you sure you want to delete ",
|
| 43 |
+
'ja': "本当に ",
|
| 44 |
+
};
|
| 45 |
+
var deleteConfirm_i18n_suff = {
|
| 46 |
+
'zh': " 吗?",
|
| 47 |
+
'en': " ?",
|
| 48 |
+
'ja': " を削除してもよろしいですか?",
|
| 49 |
+
};
|
| 50 |
+
var deleteConfirm_msg_pref = "Are you sure you want to delete ";
|
| 51 |
+
var deleteConfirm_msg_suff = " ?";
|
| 52 |
+
|
| 53 |
// gradio 页面加载好了么??? 我能动你的元素了么??
|
| 54 |
function gradioLoaded(mutations) {
|
| 55 |
for (var i = 0; i < mutations.length; i++) {
|
|
|
|
| 98 |
}
|
| 99 |
|
| 100 |
function webLocale() {
|
| 101 |
+
// console.log("webLocale", language);
|
| 102 |
if (forView_i18n.hasOwnProperty(language)) {
|
| 103 |
var forView = forView_i18n[language];
|
| 104 |
var forViewStyle = document.createElement('style');
|
| 105 |
forViewStyle.innerHTML = '.wrap>.history-message>:last-child::after { content: "' + forView + '"!important; }';
|
| 106 |
document.head.appendChild(forViewStyle);
|
| 107 |
+
}
|
| 108 |
+
if (deleteConfirm_i18n_pref.hasOwnProperty(language)) {
|
| 109 |
+
deleteConfirm_msg_pref = deleteConfirm_i18n_pref[language];
|
| 110 |
+
deleteConfirm_msg_suff = deleteConfirm_i18n_suff[language];
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|