feat: LocaleString for status

This commit is contained in:
Jason Song
2023-01-06 15:02:03 +08:00
parent a6f8f10670
commit 91dfef0425
4 changed files with 21 additions and 3 deletions

View File

@@ -3,7 +3,11 @@
package actions
import runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
import (
"code.gitea.io/gitea/modules/translation"
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
)
// Status represents the status of ActionRun, ActionRunJob, ActionTask, or ActionTaskStep
type Status int
@@ -35,6 +39,11 @@ func (s Status) String() string {
return statusNames[s]
}
// LocaleString returns the locale string name of the Status
func (s Status) LocaleString(lang translation.Locale) string {
return lang.Tr("actions.status." + s.String())
}
// IsDone returns whether the Status is final
func (s Status) IsDone() bool {
return s.In(StatusSuccess, StatusFailure, StatusCancelled, StatusSkipped)