lang.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. package i18n
  2. import "fmt"
  3. // LangMessages 各语言的消息模板
  4. type LangMessages struct {
  5. // 红包消息
  6. SendRedPacket string // "🧧 %s 发了一个红包"
  7. BlessingDefault1 string // 普通红包默认祝福语
  8. BlessingDefault2 string // 手气红包默认祝福语
  9. TotalAmount string // "总金额"
  10. Count string // "个数"
  11. CountUnit string // "个"
  12. Type string // "类型"
  13. NormalPacket string // "普通红包"
  14. LuckyPacket string // "手气红包"
  15. ValidFor string // "有效期"
  16. GrabButton string // "🎁 抢红包"
  17. GrabButtonWithNum string // "🎁 抢红包 (%d/%d)"
  18. ComeGrab string // "快来抢红包吧!"
  19. // 抢红包回调
  20. GrabSuccess string // "🎉 恭喜抢到 %.2f %s!"
  21. NotBound string // "⚠️ 请先绑定账户!私聊我发送 /bind"
  22. NotBoundDM string // 私聊绑定提示
  23. AlreadyGrab string // "您已经抢过这个红包了"
  24. PacketEnded string // "红包已结束"
  25. PacketExpd string // "红包已过期"
  26. AllGrabbed string // "红包已抢完"
  27. // 抢红包消息编辑
  28. RedPacketTitle string // "🧧 红包"
  29. GrabDetail string // "📋 领取明细 (%d/%d):"
  30. GrabRecord string // "✅ %s — %.2f %s"
  31. AllGrabbedMsg string // "🎊 红包已抢完!"
  32. ExpiredMsg string // "⏰ 红包已过期!"
  33. UserPrefix string // "用户%d" 用于无用户名时的显示
  34. // 发送者名称
  35. AdminName string // "系统管理员"
  36. // 时间单位
  37. Minutes string
  38. Hours string
  39. }
  40. // langMap 语言映射表
  41. var langMap = map[string]*LangMessages{
  42. "vi": {
  43. SendRedPacket: "🧧 %s đã gửi một lì xì",
  44. BlessingDefault1: "Chúc mừng phát tài, đại cát đại lợi",
  45. BlessingDefault2: "Lì xì may mắn, nhanh tay nhận nào!",
  46. TotalAmount: "Tổng số tiền",
  47. Count: "Số lượng",
  48. CountUnit: "cái",
  49. Type: "Loại",
  50. NormalPacket: "Lì xì thường",
  51. LuckyPacket: "Lì xì may mắn",
  52. ValidFor: "Thời hạn",
  53. GrabButton: "🎁 Nhận lì xì",
  54. GrabButtonWithNum: "🎁 Nhận lì xì (%d/%d)",
  55. ComeGrab: "Nhanh tay nhận lì xì nào!",
  56. GrabSuccess: "🎉 Chúc mừng! Bạn nhận được %.2f %s!",
  57. NotBound: "⚠️ Vui lòng liên kết tài khoản trước! Nhắn riêng /bind",
  58. 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.",
  59. AlreadyGrab: "Bạn đã nhận lì xì này rồi",
  60. PacketEnded: "Lì xì đã kết thúc",
  61. PacketExpd: "Lì xì đã hết hạn",
  62. AllGrabbed: "Lì xì đã hết",
  63. RedPacketTitle: "🧧 Lì xì",
  64. GrabDetail: "📋 Chi tiết nhận (%d/%d):",
  65. GrabRecord: "✅ %s — %.2f %s",
  66. AllGrabbedMsg: "🎊 Lì xì đã được nhận hết!",
  67. ExpiredMsg: "⏰ Lì xì đã hết hạn!",
  68. UserPrefix: "User%d",
  69. AdminName: "Quản trị viên",
  70. Minutes: "phút",
  71. Hours: "giờ",
  72. },
  73. "id": {
  74. SendRedPacket: "🧧 %s mengirim angpao",
  75. BlessingDefault1: "Gong Xi Fa Cai, semoga beruntung",
  76. BlessingDefault2: "Angpao keberuntungan, ayo ambil!",
  77. TotalAmount: "Total",
  78. Count: "Jumlah",
  79. CountUnit: "buah",
  80. Type: "Tipe",
  81. NormalPacket: "Angpao biasa",
  82. LuckyPacket: "Angpao keberuntungan",
  83. ValidFor: "Berlaku",
  84. GrabButton: "🎁 Ambil angpao",
  85. GrabButtonWithNum: "🎁 Ambil angpao (%d/%d)",
  86. ComeGrab: "Ayo ambil angpao!",
  87. GrabSuccess: "🎉 Selamat! Anda mendapat %.2f %s!",
  88. NotBound: "⚠️ Silakan hubungkan akun dulu! Kirim /bind secara privat",
  89. NotBoundDM: "⚠️ Anda belum menghubungkan akun, tidak bisa mengambil angpao.\n\nKirim /bind untuk mendapatkan link.",
  90. AlreadyGrab: "Anda sudah mengambil angpao ini",
  91. PacketEnded: "Angpao sudah berakhir",
  92. PacketExpd: "Angpao sudah kadaluarsa",
  93. AllGrabbed: "Angpao sudah habis",
  94. RedPacketTitle: "🧧 Angpao",
  95. GrabDetail: "📋 Detail pengambilan (%d/%d):",
  96. GrabRecord: "✅ %s — %.2f %s",
  97. AllGrabbedMsg: "🎊 Angpao sudah habis diambil!",
  98. ExpiredMsg: "⏰ Angpao sudah kadaluarsa!",
  99. UserPrefix: "User%d",
  100. AdminName: "Admin",
  101. Minutes: "menit",
  102. Hours: "jam",
  103. },
  104. "en": {
  105. SendRedPacket: "🧧 %s sent a red packet",
  106. BlessingDefault1: "Wishing you prosperity and good fortune",
  107. BlessingDefault2: "Lucky red packet, grab it now!",
  108. TotalAmount: "Total",
  109. Count: "Count",
  110. CountUnit: "",
  111. Type: "Type",
  112. NormalPacket: "Fixed red packet",
  113. LuckyPacket: "Lucky red packet",
  114. ValidFor: "Valid for",
  115. GrabButton: "🎁 Grab",
  116. GrabButtonWithNum: "🎁 Grab (%d/%d)",
  117. ComeGrab: "Grab the red packet now!",
  118. GrabSuccess: "🎉 Congrats! You got %.2f %s!",
  119. NotBound: "⚠️ Please bind your account first! DM me /bind",
  120. NotBoundDM: "⚠️ You haven't bound your account yet, cannot grab red packets.\n\nSend /bind to get the binding link.",
  121. AlreadyGrab: "You already grabbed this red packet",
  122. PacketEnded: "Red packet has ended",
  123. PacketExpd: "Red packet has expired",
  124. AllGrabbed: "Red packet is all taken",
  125. RedPacketTitle: "🧧 Red Packet",
  126. GrabDetail: "📋 Grab details (%d/%d):",
  127. GrabRecord: "✅ %s — %.2f %s",
  128. AllGrabbedMsg: "🎊 All grabbed!",
  129. ExpiredMsg: "⏰ Red packet expired!",
  130. UserPrefix: "User%d",
  131. AdminName: "System Admin",
  132. Minutes: "min",
  133. Hours: "hr",
  134. },
  135. "zh": {
  136. SendRedPacket: "🧧 %s 发了一个红包",
  137. BlessingDefault1: "恭喜发财,大吉大利",
  138. BlessingDefault2: "拼手气红包,快来抢!",
  139. TotalAmount: "总金额",
  140. Count: "个数",
  141. CountUnit: "个",
  142. Type: "类型",
  143. NormalPacket: "普通红包",
  144. LuckyPacket: "手气红包",
  145. ValidFor: "有效期",
  146. GrabButton: "🎁 抢红包",
  147. GrabButtonWithNum: "🎁 抢红包 (%d/%d)",
  148. ComeGrab: "快来抢红包吧!",
  149. GrabSuccess: "🎉 恭喜抢到 %.2f %s!",
  150. NotBound: "⚠️ 请先绑定账户!私聊我发送 /bind",
  151. NotBoundDM: "⚠️ 您尚未绑定平台账户,无法抢红包。\n\n请发送 /bind 获取绑定链接。",
  152. AlreadyGrab: "您已经抢过这个红包了",
  153. PacketEnded: "红包已结束",
  154. PacketExpd: "红包已过期",
  155. AllGrabbed: "红包已抢完",
  156. RedPacketTitle: "🧧 红包",
  157. GrabDetail: "📋 领取明细 (%d/%d):",
  158. GrabRecord: "✅ %s — %.2f %s",
  159. AllGrabbedMsg: "🎊 红包已抢完!",
  160. ExpiredMsg: "⏰ 红包已过期!",
  161. UserPrefix: "用户%d",
  162. AdminName: "系统管理员",
  163. Minutes: "分钟",
  164. Hours: "小时",
  165. },
  166. }
  167. // GetLang 获取指定语言的消息,找不到则默认越南语
  168. func GetLang(lang string) *LangMessages {
  169. if m, ok := langMap[lang]; ok {
  170. return m
  171. }
  172. return langMap["vi"]
  173. }
  174. // FormatExpireTime 根据语言格式化过期时间文本
  175. func FormatExpireTime(expireMinutes int, lang string) string {
  176. m := GetLang(lang)
  177. if expireMinutes <= 0 {
  178. return fmt.Sprintf("10%s", m.Minutes)
  179. }
  180. if expireMinutes >= 60 {
  181. hours := expireMinutes / 60
  182. mins := expireMinutes % 60
  183. if mins > 0 {
  184. return fmt.Sprintf("%d%s%d%s", hours, m.Hours, mins, m.Minutes)
  185. }
  186. return fmt.Sprintf("%d%s", hours, m.Hours)
  187. }
  188. return fmt.Sprintf("%d%s", expireMinutes, m.Minutes)
  189. }
  190. // DefaultSymbol 根据语言返回默认币种
  191. func DefaultSymbol(lang string) string {
  192. switch lang {
  193. case "vi":
  194. return "VND"
  195. case "id":
  196. return "IDR"
  197. case "en":
  198. return "USD"
  199. case "zh":
  200. return "CNY"
  201. default:
  202. return "VND"
  203. }
  204. }
  205. // PacketTypeText 获取红包类型文本
  206. func PacketTypeText(packetType int, lang string) string {
  207. m := GetLang(lang)
  208. if packetType == 1 {
  209. return m.NormalPacket
  210. }
  211. return m.LuckyPacket
  212. }