- Updated silent.go to replace hardcoded strings with i18n keys for user feedback. - Enhanced telegraph.go to use i18n for error messages and prompts. - Modified update.go to implement i18n for version update notifications and errors. - Refactored dir.go to utilize i18n for help messages related to directory operations. - Updated parse.go to replace static text with i18n keys for parsed text entities. - Enhanced rule.go to use i18n for rule management help messages. - Refactored storage.go to implement i18n for storage selection prompts. - Updated task.go to utilize i18n for task addition notifications. - Added new i18n keys in keys.go for various messages. - Updated Chinese localization in zh-Hans.yaml to reflect new i18n keys and messages.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package msgelem
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/charmbracelet/log"
|
|
"github.com/gotd/td/telegram/message/entity"
|
|
"github.com/gotd/td/telegram/message/styling"
|
|
"github.com/gotd/td/tg"
|
|
"github.com/krau/SaveAny-Bot/common/i18n"
|
|
"github.com/krau/SaveAny-Bot/common/i18n/i18nk"
|
|
)
|
|
|
|
func BuildTaskAddedEntities(
|
|
ctx context.Context,
|
|
filename string,
|
|
queueLength int,
|
|
) (string, []tg.MessageEntityClass) {
|
|
entityBuilder := entity.Builder{}
|
|
var entities []tg.MessageEntityClass
|
|
text := i18n.T(i18nk.BotMsgTasksInfoAddedToQueueFull, map[string]any{
|
|
"Filename": filename,
|
|
"QueueLength": queueLength,
|
|
})
|
|
if err := styling.Perform(&entityBuilder,
|
|
styling.Plain(i18n.T(i18nk.BotMsgTasksInfoAddedToQueuePrefix, nil)),
|
|
styling.Plain(i18n.T(i18nk.BotMsgTasksInfoFilenamePrefix, nil)),
|
|
styling.Code(filename),
|
|
styling.Plain(i18n.T(i18nk.BotMsgTasksInfoQueueLengthPrefix, nil)),
|
|
styling.Bold(strconv.Itoa(queueLength)),
|
|
); err != nil {
|
|
log.FromContext(ctx).Errorf("Failed to build entity: %s", err)
|
|
} else {
|
|
text, entities = entityBuilder.Complete()
|
|
}
|
|
return text, entities
|
|
}
|