Skip to content

Commit b0dd490

Browse files
fogtiGusted
authored andcommitted
feat(repo,locale): merge PR/issues cases for some repo/issue strings (go-gitea#7092)
- Merge `archive.nocomment` and `comment.blocked_by_user`'s variants for issue and pull request to a unified string and no longer have a issue and pull request variant. - Fixes go-gitea#6443 Signed-off-by: Ellen Emilia Anna Zscheile <[email protected]> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7092 Reviewed-by: Panagiotis "Ivory" Vasilopoulos <[email protected]> Reviewed-by: Gusted <[email protected]> Co-authored-by: Ellen Emilia Anna Zscheile <[email protected]> Co-committed-by: Ellen Emilia Anna Zscheile <[email protected]>
1 parent 3769259 commit b0dd490

File tree

5 files changed

+11
-29
lines changed

5 files changed

+11
-29
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,7 @@ template.invalid = Must select a template repository
12171217

12181218
archive.title = This repository is archived. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
12191219
archive.title_date = This repository has been archived on %s. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
1220-
archive.issue.nocomment = This repository is archived. You cannot comment on issues.
1221-
archive.pull.nocomment = This repository is archived. You cannot comment on pull requests.
1220+
archive.nocomment = Commenting is not possible because the repository is archived.
12221221
archive.pull.noreview = This repository is archived. You cannot review pull requests.
12231222

12241223
form.reach_limit_of_creation_1 = The owner has already reached the limit of %d repository.
@@ -1882,7 +1881,7 @@ issues.content_history.delete_from_history_confirm = Delete from history?
18821881
issues.content_history.options = Options
18831882
issues.reference_link = Reference: %s
18841883
issues.blocked_by_user = You cannot create issues in this repository because you are blocked by the repository owner.
1885-
issues.comment.blocked_by_user = You cannot comment on this issue because you are blocked by the repository owner or the poster of the issue.
1884+
comment.blocked_by_user = Commenting is not possible because you are blocked by the repository owner or the author.
18861885
issues.reopen.blocked_by_user = You cannot reopen this issue because you are blocked by the repository owner or the poster of this issue.
18871886
issues.summary_card_alt = Summary card of an issue titled "%s" in repository %s
18881887

@@ -1967,7 +1966,6 @@ pulls.waiting_count_1 = %d waiting review
19671966
pulls.waiting_count_n = %d waiting reviews
19681967
pulls.wrong_commit_id = commit id must be a commit id on the target branch
19691968
pulls.blocked_by_user = You cannot create a pull request on this repository because you are blocked by the repository owner.
1970-
pulls.comment.blocked_by_user = You cannot comment on this pull request because you are blocked by the repository owner or the poster of the pull request.
19711969

19721970
pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled.
19731971
pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually.

routers/web/repo/issue.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,11 +3255,7 @@ func NewComment(ctx *context.Context) {
32553255
comment, err := issue_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
32563256
if err != nil {
32573257
if errors.Is(err, user_model.ErrBlockedByUser) {
3258-
if issue.IsPull {
3259-
ctx.JSONError(ctx.Tr("repo.pulls.comment.blocked_by_user"))
3260-
} else {
3261-
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_by_user"))
3262-
}
3258+
ctx.JSONError(ctx.Tr("repo.comment.blocked_by_user"))
32633259
} else {
32643260
ctx.ServerError("CreateIssueComment", err)
32653261
}

routers/web/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,8 @@ func MergePullRequest(ctx *context.Context) {
13211321
} else if models.IsErrMergeConflicts(err) {
13221322
conflictError := err.(models.ErrMergeConflicts)
13231323
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
1324-
"Message": ctx.Tr("repo.editor.merge_conflict"),
1325-
"Summary": ctx.Tr("repo.editor.merge_conflict_summary"),
1324+
"Message": ctx.Tr("repo.pulls.merge_conflict"),
1325+
"Summary": ctx.Tr("repo.pulls.merge_conflict_summary"),
13261326
"Details": utils.SanitizeFlashErrorString(conflictError.StdErr) + "<br>" + utils.SanitizeFlashErrorString(conflictError.StdOut),
13271327
})
13281328
if err != nil {

templates/repo/issue/view_content.tmpl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,17 @@
116116
</div>
117117
{{else if .Repository.IsArchived}}
118118
<div class="ui warning message tw-text-center">
119-
{{if .Issue.IsPull}}
120-
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
121-
{{else}}
122-
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
123-
{{end}}
119+
{{ctx.Locale.Tr "repo.archive.nocomment"}}
124120
</div>
125121
{{end}}
126122
{{else if .IsBlocked}}
127123
<div class="ui warning message">
128-
{{if .Issue.IsPull}}
129-
{{ctx.Locale.Tr "repo.pulls.comment.blocked_by_user"}}
130-
{{else}}
131-
{{ctx.Locale.Tr "repo.issues.comment.blocked_by_user"}}
132-
{{end}}
124+
{{ctx.Locale.Tr "repo.comment.blocked_by_user"}}
133125
</div>
134126
{{else}} {{/* not .IsSigned */}}
135127
{{if .Repository.IsArchived}}
136128
<div class="ui warning message tw-text-center">
137-
{{if .Issue.IsPull}}
138-
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
139-
{{else}}
140-
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
141-
{{end}}
129+
{{ctx.Locale.Tr "repo.archive.nocomment"}}
142130
</div>
143131
{{else}}
144132
<div class="ui warning message">

tests/integration/block_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func TestBlockActions(t *testing.T) {
236236
// Ensures that comment creation on doer's owned repositories and doer's
237237
// posted issues are blocked.
238238
t.Run("Comment creation", func(t *testing.T) {
239-
expectedMessage := locale.Tr("repo.issues.comment.blocked_by_user")
239+
expectedMessage := locale.Tr("repo.comment.blocked_by_user")
240240

241241
t.Run("Blocked by repository owner", func(t *testing.T) {
242242
defer tests.PrintCurrentTest(t)()
@@ -258,7 +258,7 @@ func TestBlockActions(t *testing.T) {
258258
resp = session.MakeRequest(t, req, http.StatusOK)
259259
htmlDoc := NewHTMLParser(t, resp.Body)
260260
msg := htmlDoc.doc.Find("div .warning").Text()
261-
assert.Contains(t, msg, "You cannot comment on this issue because you are blocked")
261+
assert.Contains(t, msg, expectedMessage)
262262
})
263263

264264
t.Run("Blocked by issue poster", func(t *testing.T) {
@@ -285,7 +285,7 @@ func TestBlockActions(t *testing.T) {
285285
resp = session.MakeRequest(t, req, http.StatusOK)
286286
htmlDoc := NewHTMLParser(t, resp.Body)
287287
msg := htmlDoc.doc.Find("div .warning").Text()
288-
assert.Contains(t, msg, "You cannot comment on this issue because you are blocked")
288+
assert.Contains(t, msg, expectedMessage)
289289
})
290290
})
291291

0 commit comments

Comments
 (0)