messages.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package worker
  2. import (
  3. "net/http"
  4. "github.com/qor5/x/i18n"
  5. "github.com/qor5/admin/presets"
  6. )
  7. const I18nWorkerKey i18n.ModuleKey = "I18nWorkerKey"
  8. type Messages struct {
  9. StatusNew string
  10. StatusScheduled string
  11. StatusRunning string
  12. StatusCancelled string
  13. StatusDone string
  14. StatusException string
  15. StatusKilled string
  16. FilterTabAll string
  17. FilterTabRunning string
  18. FilterTabScheduled string
  19. FilterTabDone string
  20. FilterTabErrors string
  21. ActionCancelJob string
  22. ActionAbortJob string
  23. ActionUpdateJob string
  24. ActionRerunJob string
  25. DetailTitleStatus string
  26. DetailTitleLog string
  27. NoticeJobCannotBeAborted string
  28. NoticeJobWontBeExecuted string
  29. ScheduleTime string
  30. DateTimePickerClearText string
  31. DateTimePickerOkText string
  32. PleaseSelectJob string
  33. }
  34. var Messages_en_US = &Messages{
  35. StatusNew: "New",
  36. StatusScheduled: "Scheduled",
  37. StatusRunning: "Running",
  38. StatusCancelled: "Cancelled",
  39. StatusDone: "Done",
  40. StatusException: "Exception",
  41. StatusKilled: "Killed",
  42. FilterTabAll: "All Jobs",
  43. FilterTabRunning: "Running",
  44. FilterTabScheduled: "Scheduled",
  45. FilterTabDone: "Done",
  46. FilterTabErrors: "Errors",
  47. ActionCancelJob: "Cancel Job",
  48. ActionAbortJob: "Abort Job",
  49. ActionUpdateJob: "Update Job",
  50. ActionRerunJob: "Rerun Job",
  51. DetailTitleStatus: "Status",
  52. DetailTitleLog: "Log",
  53. NoticeJobCannotBeAborted: "This job cannot be aborted/canceled/updated due to its status change",
  54. NoticeJobWontBeExecuted: "This job won't be executed due to code being deleted/modified",
  55. ScheduleTime: "Schedule Time",
  56. DateTimePickerClearText: "Clear",
  57. DateTimePickerOkText: "OK",
  58. PleaseSelectJob: "Please select job",
  59. }
  60. var Messages_zh_CN = &Messages{
  61. StatusNew: "新建",
  62. StatusScheduled: "计划",
  63. StatusRunning: "运行中",
  64. StatusCancelled: "取消",
  65. StatusDone: "完成",
  66. StatusException: "错误",
  67. StatusKilled: "中止",
  68. FilterTabAll: "全部",
  69. FilterTabRunning: "运行中",
  70. FilterTabScheduled: "计划",
  71. FilterTabDone: "完成",
  72. FilterTabErrors: "错误",
  73. ActionCancelJob: "取消Job",
  74. ActionAbortJob: "中止Job",
  75. ActionUpdateJob: "更新Job",
  76. ActionRerunJob: "重跑Job",
  77. DetailTitleStatus: "状态",
  78. DetailTitleLog: "日志",
  79. NoticeJobCannotBeAborted: "Job状态已经改变,不能被中止/取消/更新",
  80. NoticeJobWontBeExecuted: "Job代码被删除/修改, 这个Job不会被执行",
  81. ScheduleTime: "执行时间",
  82. DateTimePickerClearText: "清空",
  83. DateTimePickerOkText: "确定",
  84. PleaseSelectJob: "请选择Job",
  85. }
  86. func getTStatus(msgr *Messages, status string) string {
  87. switch status {
  88. case JobStatusNew:
  89. return msgr.StatusNew
  90. case JobStatusScheduled:
  91. return msgr.StatusScheduled
  92. case JobStatusRunning:
  93. return msgr.StatusRunning
  94. case JobStatusCancelled:
  95. return msgr.StatusCancelled
  96. case JobStatusDone:
  97. return msgr.StatusDone
  98. case JobStatusException:
  99. return msgr.StatusException
  100. case JobStatusKilled:
  101. return msgr.StatusKilled
  102. }
  103. return status
  104. }
  105. func getTJob(r *http.Request, v string) string {
  106. return i18n.PT(r, presets.ModelsI18nModuleKey, "WorkerJob", v)
  107. }