| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- package i18n
- import "fmt"
- // LangMessages 各语言的消息模板
- type LangMessages struct {
- // 红包消息
- SendRedPacket string // "🧧 %s 发了一个红包"
- BlessingDefault1 string // 普通红包默认祝福语
- BlessingDefault2 string // 手气红包默认祝福语
- TotalAmount string // "总金额"
- Count string // "个数"
- CountUnit string // "个"
- Type string // "类型"
- NormalPacket string // "普通红包"
- LuckyPacket string // "手气红包"
- ValidFor string // "有效期"
- GrabButton string // "🎁 抢红包"
- GrabButtonWithNum string // "🎁 抢红包 (%d/%d)"
- ComeGrab string // "快来抢红包吧!"
- // 抢红包回调
- GrabSuccess string // "🎉 恭喜抢到 %.2f %s!"
- NotBound string // "⚠️ 请先绑定账户!私聊我发送 /bind"
- NotBoundDM string // 私聊绑定提示
- AlreadyGrab string // "您已经抢过这个红包了"
- PacketEnded string // "红包已结束"
- PacketExpd string // "红包已过期"
- AllGrabbed string // "红包已抢完"
- // 抢红包消息编辑
- RedPacketTitle string // "🧧 红包"
- GrabDetail string // "📋 领取明细 (%d/%d):"
- GrabRecord string // "✅ %s — %.2f %s"
- AllGrabbedMsg string // "🎊 红包已抢完!"
- ExpiredMsg string // "⏰ 红包已过期!"
- UserPrefix string // "用户%d" 用于无用户名时的显示
- // 发送者名称
- AdminName string // "系统管理员"
- // 时间单位
- Minutes string
- Hours string
- }
- // langMap 语言映射表
- var langMap = map[string]*LangMessages{
- "vi": {
- SendRedPacket: "🧧 %s đã gửi một lì xì",
- BlessingDefault1: "Chúc mừng phát tài, đại cát đại lợi",
- BlessingDefault2: "Lì xì may mắn, nhanh tay nhận nào!",
- TotalAmount: "Tổng số tiền",
- Count: "Số lượng",
- CountUnit: "cái",
- Type: "Loại",
- NormalPacket: "Lì xì thường",
- LuckyPacket: "Lì xì may mắn",
- ValidFor: "Thời hạn",
- GrabButton: "🎁 Nhận lì xì",
- GrabButtonWithNum: "🎁 Nhận lì xì (%d/%d)",
- ComeGrab: "Nhanh tay nhận lì xì nào!",
- GrabSuccess: "🎉 Chúc mừng! Bạn nhận được %.2f %s!",
- NotBound: "⚠️ Vui lòng liên kết tài khoản trước! Nhắn riêng /bind",
- NotBoundDM: "⚠️ Bạn chưa liên kết tài khoản, không thể nhận lì xì.\n\nGửi /bind để nhận link liên kết.",
- AlreadyGrab: "Bạn đã nhận lì xì này rồi",
- PacketEnded: "Lì xì đã kết thúc",
- PacketExpd: "Lì xì đã hết hạn",
- AllGrabbed: "Lì xì đã hết",
- RedPacketTitle: "🧧 Lì xì",
- GrabDetail: "📋 Chi tiết nhận (%d/%d):",
- GrabRecord: "✅ %s — %.2f %s",
- AllGrabbedMsg: "🎊 Lì xì đã được nhận hết!",
- ExpiredMsg: "⏰ Lì xì đã hết hạn!",
- UserPrefix: "User%d",
- AdminName: "Quản trị viên",
- Minutes: "phút",
- Hours: "giờ",
- },
- "id": {
- SendRedPacket: "🧧 %s mengirim angpao",
- BlessingDefault1: "Gong Xi Fa Cai, semoga beruntung",
- BlessingDefault2: "Angpao keberuntungan, ayo ambil!",
- TotalAmount: "Total",
- Count: "Jumlah",
- CountUnit: "buah",
- Type: "Tipe",
- NormalPacket: "Angpao biasa",
- LuckyPacket: "Angpao keberuntungan",
- ValidFor: "Berlaku",
- GrabButton: "🎁 Ambil angpao",
- GrabButtonWithNum: "🎁 Ambil angpao (%d/%d)",
- ComeGrab: "Ayo ambil angpao!",
- GrabSuccess: "🎉 Selamat! Anda mendapat %.2f %s!",
- NotBound: "⚠️ Silakan hubungkan akun dulu! Kirim /bind secara privat",
- NotBoundDM: "⚠️ Anda belum menghubungkan akun, tidak bisa mengambil angpao.\n\nKirim /bind untuk mendapatkan link.",
- AlreadyGrab: "Anda sudah mengambil angpao ini",
- PacketEnded: "Angpao sudah berakhir",
- PacketExpd: "Angpao sudah kadaluarsa",
- AllGrabbed: "Angpao sudah habis",
- RedPacketTitle: "🧧 Angpao",
- GrabDetail: "📋 Detail pengambilan (%d/%d):",
- GrabRecord: "✅ %s — %.2f %s",
- AllGrabbedMsg: "🎊 Angpao sudah habis diambil!",
- ExpiredMsg: "⏰ Angpao sudah kadaluarsa!",
- UserPrefix: "User%d",
- AdminName: "Admin",
- Minutes: "menit",
- Hours: "jam",
- },
- "en": {
- SendRedPacket: "🧧 %s sent a red packet",
- BlessingDefault1: "Wishing you prosperity and good fortune",
- BlessingDefault2: "Lucky red packet, grab it now!",
- TotalAmount: "Total",
- Count: "Count",
- CountUnit: "",
- Type: "Type",
- NormalPacket: "Fixed red packet",
- LuckyPacket: "Lucky red packet",
- ValidFor: "Valid for",
- GrabButton: "🎁 Grab",
- GrabButtonWithNum: "🎁 Grab (%d/%d)",
- ComeGrab: "Grab the red packet now!",
- GrabSuccess: "🎉 Congrats! You got %.2f %s!",
- NotBound: "⚠️ Please bind your account first! DM me /bind",
- NotBoundDM: "⚠️ You haven't bound your account yet, cannot grab red packets.\n\nSend /bind to get the binding link.",
- AlreadyGrab: "You already grabbed this red packet",
- PacketEnded: "Red packet has ended",
- PacketExpd: "Red packet has expired",
- AllGrabbed: "Red packet is all taken",
- RedPacketTitle: "🧧 Red Packet",
- GrabDetail: "📋 Grab details (%d/%d):",
- GrabRecord: "✅ %s — %.2f %s",
- AllGrabbedMsg: "🎊 All grabbed!",
- ExpiredMsg: "⏰ Red packet expired!",
- UserPrefix: "User%d",
- AdminName: "System Admin",
- Minutes: "min",
- Hours: "hr",
- },
- "zh": {
- SendRedPacket: "🧧 %s 发了一个红包",
- BlessingDefault1: "恭喜发财,大吉大利",
- BlessingDefault2: "拼手气红包,快来抢!",
- TotalAmount: "总金额",
- Count: "个数",
- CountUnit: "个",
- Type: "类型",
- NormalPacket: "普通红包",
- LuckyPacket: "手气红包",
- ValidFor: "有效期",
- GrabButton: "🎁 抢红包",
- GrabButtonWithNum: "🎁 抢红包 (%d/%d)",
- ComeGrab: "快来抢红包吧!",
- GrabSuccess: "🎉 恭喜抢到 %.2f %s!",
- NotBound: "⚠️ 请先绑定账户!私聊我发送 /bind",
- NotBoundDM: "⚠️ 您尚未绑定平台账户,无法抢红包。\n\n请发送 /bind 获取绑定链接。",
- AlreadyGrab: "您已经抢过这个红包了",
- PacketEnded: "红包已结束",
- PacketExpd: "红包已过期",
- AllGrabbed: "红包已抢完",
- RedPacketTitle: "🧧 红包",
- GrabDetail: "📋 领取明细 (%d/%d):",
- GrabRecord: "✅ %s — %.2f %s",
- AllGrabbedMsg: "🎊 红包已抢完!",
- ExpiredMsg: "⏰ 红包已过期!",
- UserPrefix: "用户%d",
- AdminName: "系统管理员",
- Minutes: "分钟",
- Hours: "小时",
- },
- }
- // GetLang 获取指定语言的消息,找不到则默认越南语
- func GetLang(lang string) *LangMessages {
- if m, ok := langMap[lang]; ok {
- return m
- }
- return langMap["vi"]
- }
- // FormatExpireTime 根据语言格式化过期时间文本
- func FormatExpireTime(expireMinutes int, lang string) string {
- m := GetLang(lang)
- if expireMinutes <= 0 {
- return fmt.Sprintf("10%s", m.Minutes)
- }
- if expireMinutes >= 60 {
- hours := expireMinutes / 60
- mins := expireMinutes % 60
- if mins > 0 {
- return fmt.Sprintf("%d%s%d%s", hours, m.Hours, mins, m.Minutes)
- }
- return fmt.Sprintf("%d%s", hours, m.Hours)
- }
- return fmt.Sprintf("%d%s", expireMinutes, m.Minutes)
- }
- // DefaultSymbol 根据语言返回默认币种
- func DefaultSymbol(lang string) string {
- switch lang {
- case "vi":
- return "VND"
- case "id":
- return "IDR"
- case "en":
- return "USD"
- case "zh":
- return "CNY"
- default:
- return "VND"
- }
- }
- // PacketTypeText 获取红包类型文本
- func PacketTypeText(packetType int, lang string) string {
- m := GetLang(lang)
- if packetType == 1 {
- return m.NormalPacket
- }
- return m.LuckyPacket
- }
|