From fd3b17a36047b2293f3e67da6de6f69f6f208600 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Sun, 21 Dec 2025 12:59:14 +0800 Subject: [PATCH] fix(i18n): add cancel button text --- common/i18n/i18nk/keys.go | 2 +- common/i18n/locale/en.yaml | 1 + common/i18n/locale/zh-Hans.yaml | 1 + common/utils/tgutil/message.go | 4 +++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/i18n/i18nk/keys.go b/common/i18n/i18nk/keys.go index 5dde3e7..6c55b19 100644 --- a/common/i18n/i18nk/keys.go +++ b/common/i18n/i18nk/keys.go @@ -25,6 +25,7 @@ const ( BotMsgCmdUnwatch Key = "bot.msg.cmd.unwatch" BotMsgCmdUpdate Key = "bot.msg.cmd.update" BotMsgCmdWatch Key = "bot.msg.cmd.watch" + BotMsgCommonCancelButtonText Key = "bot.msg.common.cancel_button_text" BotMsgCommonErrorBuildDirSelectKeyboardFailed Key = "bot.msg.common.error_build_dir_select_keyboard_failed" BotMsgCommonErrorBuildStorageSelectKeyboardFailed Key = "bot.msg.common.error_build_storage_select_keyboard_failed" BotMsgCommonErrorBuildStorageSelectMessageFailed Key = "bot.msg.common.error_build_storage_select_message_failed" @@ -230,5 +231,4 @@ const ( LifetimeUserLoginFailed Key = "lifetime.user_login_failed" ParserPluginLoadFailed Key = "parser.plugin.load_failed" ParserPluginLoadedDir Key = "parser.plugin.loaded_dir" - BotMsgCancelCancelTask Key = "bot.msg.cancel.cancel.task" ) diff --git a/common/i18n/locale/en.yaml b/common/i18n/locale/en.yaml index d72d02e..eff667f 100644 --- a/common/i18n/locale/en.yaml +++ b/common/i18n/locale/en.yaml @@ -84,6 +84,7 @@ bot: This will watch chat with ID -1002229835658 and save all media messages containing "plana". common: + cancel_button_text: "Cancel" error_invalid_regex: "Invalid regex: {{.Error}}" error_invalid_msg_id_range: "Invalid message ID range: {{.Error}}" error_invalid_id_or_username: "Invalid ID or username: {{.Error}}" diff --git a/common/i18n/locale/zh-Hans.yaml b/common/i18n/locale/zh-Hans.yaml index 41214bd..2200924 100644 --- a/common/i18n/locale/zh-Hans.yaml +++ b/common/i18n/locale/zh-Hans.yaml @@ -84,6 +84,7 @@ bot: 这将监听 ID 为 -1002229835658 的聊天, 并转存所有包含 "plana" 的媒体消息 common: + cancel_button_text: "取消任务" error_invalid_regex: "无效的正则表达式: {{.Error}}" error_invalid_msg_id_range: "无效的消息ID范围: {{.Error}}" error_invalid_id_or_username: "无效的ID或用户名: {{.Error}}" diff --git a/common/utils/tgutil/message.go b/common/utils/tgutil/message.go index 91ae085..3c9524a 100644 --- a/common/utils/tgutil/message.go +++ b/common/utils/tgutil/message.go @@ -17,6 +17,8 @@ import ( "github.com/gotd/td/constant" "github.com/gotd/td/tg" "github.com/krau/SaveAny-Bot/common/cache" + "github.com/krau/SaveAny-Bot/common/i18n" + "github.com/krau/SaveAny-Bot/common/i18n/i18nk" "github.com/krau/SaveAny-Bot/common/utils/strutil" "github.com/rs/xid" ) @@ -96,7 +98,7 @@ func GenFileNameFromMessage(message tg.Message) string { func BuildCancelButton(taskID string) tg.KeyboardButtonClass { return &tg.KeyboardButtonCallback{ - Text: "取消任务", + Text: i18n.T(i18nk.BotMsgCommonCancelButtonText, nil), Data: fmt.Appendf(nil, "cancel %s", taskID), } }