summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-02-15 05:48:45 +0800
committerGitHub <noreply@github.com>2024-02-14 21:48:45 +0000
commitf3eb835886031df7a562abc123c3f6011c81eca8 (patch)
tree6db218680b00a81f2ea46675d5dde94642a232b9 /models
parent94d06be035bac468129903c9f32e785baf3c1c3b (diff)
downloadgitea-f3eb835886031df7a562abc123c3f6011c81eca8.tar.gz
gitea-f3eb835886031df7a562abc123c3f6011c81eca8.zip
Refactor locale&string&template related code (#29165)
Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like #29059 , to render the error messages correctly.
Diffstat (limited to 'models')
-rw-r--r--models/actions/runner.go2
-rw-r--r--models/actions/status.go2
-rw-r--r--models/git/commit_status.go2
-rw-r--r--models/issues/comment.go4
-rw-r--r--models/shared/types/ownertype.go10
5 files changed, 10 insertions, 10 deletions
diff --git a/models/actions/runner.go b/models/actions/runner.go
index 4103ba4477..b646146ee6 100644
--- a/models/actions/runner.go
+++ b/models/actions/runner.go
@@ -97,7 +97,7 @@ func (r *ActionRunner) StatusName() string {
}
func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string {
- return lang.Tr("actions.runners.status." + r.StatusName())
+ return lang.TrString("actions.runners.status." + r.StatusName())
}
func (r *ActionRunner) IsOnline() bool {
diff --git a/models/actions/status.go b/models/actions/status.go
index c97578f2ac..eda2234137 100644
--- a/models/actions/status.go
+++ b/models/actions/status.go
@@ -41,7 +41,7 @@ func (s Status) String() string {
// LocaleString returns the locale string name of the Status
func (s Status) LocaleString(lang translation.Locale) string {
- return lang.Tr("actions.status." + s.String())
+ return lang.TrString("actions.status." + s.String())
}
// IsDone returns whether the Status is final
diff --git a/models/git/commit_status.go b/models/git/commit_status.go
index 1118b6cc8c..2d1d1bcb06 100644
--- a/models/git/commit_status.go
+++ b/models/git/commit_status.go
@@ -194,7 +194,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {
// LocaleString returns the locale string name of the Status
func (status *CommitStatus) LocaleString(lang translation.Locale) string {
- return lang.Tr("repo.commitstatus." + status.State.String())
+ return lang.TrString("repo.commitstatus." + status.State.String())
}
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
diff --git a/models/issues/comment.go b/models/issues/comment.go
index a586caf1b5..fa0eb3cc0f 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -210,12 +210,12 @@ const (
// LocaleString returns the locale string name of the role
func (r RoleInRepo) LocaleString(lang translation.Locale) string {
- return lang.Tr("repo.issues.role." + string(r))
+ return lang.TrString("repo.issues.role." + string(r))
}
// LocaleHelper returns the locale tooltip of the role
func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
- return lang.Tr("repo.issues.role." + string(r) + "_helper")
+ return lang.TrString("repo.issues.role." + string(r) + "_helper")
}
// Comment represents a comment in commit and issue page.
diff --git a/models/shared/types/ownertype.go b/models/shared/types/ownertype.go
index e6fe4e4cfd..a1d46c986f 100644
--- a/models/shared/types/ownertype.go
+++ b/models/shared/types/ownertype.go
@@ -17,13 +17,13 @@ const (
func (o OwnerType) LocaleString(locale translation.Locale) string {
switch o {
case OwnerTypeSystemGlobal:
- return locale.Tr("concept_system_global")
+ return locale.TrString("concept_system_global")
case OwnerTypeIndividual:
- return locale.Tr("concept_user_individual")
+ return locale.TrString("concept_user_individual")
case OwnerTypeRepository:
- return locale.Tr("concept_code_repository")
+ return locale.TrString("concept_code_repository")
case OwnerTypeOrganization:
- return locale.Tr("concept_user_organization")
+ return locale.TrString("concept_user_organization")
}
- return locale.Tr("unknown")
+ return locale.TrString("unknown")
}