mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 04:09:29 +02:00
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. (cherry picked from commit f3eb835886031df7a562abc123c3f6011c81eca8) Conflicts: modules/web/middleware/binding.go routers/web/feed/convert.go tests/integration/branches_test.go tests/integration/repo_branch_test.go trivial context conflicts
This commit is contained in:
parent
d565d85160
commit
65248945c9
78 changed files with 359 additions and 286 deletions
|
@ -300,9 +300,9 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
|
|||
message := strings.TrimSpace(form.CommitSummary)
|
||||
if len(message) == 0 {
|
||||
if isNewFile {
|
||||
message = ctx.Tr("repo.editor.add", form.TreePath)
|
||||
message = ctx.Locale.TrString("repo.editor.add", form.TreePath)
|
||||
} else {
|
||||
message = ctx.Tr("repo.editor.update", form.TreePath)
|
||||
message = ctx.Locale.TrString("repo.editor.update", form.TreePath)
|
||||
}
|
||||
}
|
||||
form.CommitMessage = strings.TrimSpace(form.CommitMessage)
|
||||
|
@ -479,7 +479,7 @@ func DiffPreviewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if diff.NumFiles == 0 {
|
||||
ctx.PlainText(http.StatusOK, ctx.Tr("repo.editor.no_changes_to_show"))
|
||||
ctx.PlainText(http.StatusOK, ctx.Locale.TrString("repo.editor.no_changes_to_show"))
|
||||
return
|
||||
}
|
||||
ctx.Data["File"] = diff.Files[0]
|
||||
|
@ -546,7 +546,7 @@ func DeleteFilePost(ctx *context.Context) {
|
|||
|
||||
message := strings.TrimSpace(form.CommitSummary)
|
||||
if len(message) == 0 {
|
||||
message = ctx.Tr("repo.editor.delete", ctx.Repo.TreePath)
|
||||
message = ctx.Locale.TrString("repo.editor.delete", ctx.Repo.TreePath)
|
||||
}
|
||||
form.CommitMessage = strings.TrimSpace(form.CommitMessage)
|
||||
if len(form.CommitMessage) > 0 {
|
||||
|
@ -755,7 +755,7 @@ func UploadFilePost(ctx *context.Context) {
|
|||
if dir == "" {
|
||||
dir = "/"
|
||||
}
|
||||
message = ctx.Tr("repo.editor.upload_files_to_dir", dir)
|
||||
message = ctx.Locale.TrString("repo.editor.upload_files_to_dir", dir)
|
||||
}
|
||||
|
||||
form.CommitMessage = strings.TrimSpace(form.CommitMessage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue