feat(repo,locale): merge PR/issues cases for some repo/issue strings

- `nocomment` (originally propsed in https://codeberg.org/forgejo/forgejo/pulls/6439#issue-941717 by @0ko)
- `comment.blocked_by_user`

Fixes #6443

Signed-off-by: Ellen Emilia Anna Zscheile <fogti+devel@ytrizja.de>
This commit is contained in:
Ellen Emilia Anna Zscheile 2025-03-02 00:55:36 +01:00
parent da8aa01466
commit 7441ac33b9
4 changed files with 7 additions and 25 deletions

View file

@ -1217,8 +1217,7 @@ template.invalid = Must select a template repository
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.
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.
archive.issue.nocomment = This repository is archived. You cannot comment on issues.
archive.pull.nocomment = This repository is archived. You cannot comment on pull requests.
archive.nocomment = Commenting is not possible because the repository is archived.
archive.pull.noreview = This repository is archived. You cannot review pull requests.
form.reach_limit_of_creation_1 = The owner has already reached the limit of %d repository.
@ -1881,7 +1880,7 @@ issues.content_history.delete_from_history_confirm = Delete from history?
issues.content_history.options = Options
issues.reference_link = Reference: %s
issues.blocked_by_user = You cannot create issues in this repository because you are blocked by the repository owner.
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.
comment.blocked_by_user = Commenting is not possible because you are blocked by the repository owner or the author.
issues.reopen.blocked_by_user = You cannot reopen this issue because you are blocked by the repository owner or the poster of this issue.
issues.summary_card_alt = Summary card of an issue titled "%s" in repository %s
@ -1966,7 +1965,6 @@ pulls.waiting_count_1 = %d waiting review
pulls.waiting_count_n = %d waiting reviews
pulls.wrong_commit_id = commit id must be a commit id on the target branch
pulls.blocked_by_user = You cannot create a pull request on this repository because you are blocked by the repository owner.
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.
pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled.
pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually.

View file

@ -3253,11 +3253,7 @@ func NewComment(ctx *context.Context) {
comment, err := issue_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
if err != nil {
if errors.Is(err, user_model.ErrBlockedByUser) {
if issue.IsPull {
ctx.JSONError(ctx.Tr("repo.pulls.comment.blocked_by_user"))
} else {
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_by_user"))
}
ctx.JSONError(ctx.Tr("repo.comment.blocked_by_user"))
} else {
ctx.ServerError("CreateIssueComment", err)
}

View file

@ -116,29 +116,17 @@
</div>
{{else if .Repository.IsArchived}}
<div class="ui warning message tw-text-center">
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
{{else}}
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
{{end}}
{{ctx.Locale.Tr "repo.archive.nocomment"}}
</div>
{{end}}
{{else if .IsBlocked}}
<div class="ui warning message">
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.pulls.comment.blocked_by_user"}}
{{else}}
{{ctx.Locale.Tr "repo.issues.comment.blocked_by_user"}}
{{end}}
{{ctx.Locale.Tr "repo.comment.blocked_by_user"}}
</div>
{{else}} {{/* not .IsSigned */}}
{{if .Repository.IsArchived}}
<div class="ui warning message tw-text-center">
{{if .Issue.IsPull}}
{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}
{{else}}
{{ctx.Locale.Tr "repo.archive.issue.nocomment"}}
{{end}}
{{ctx.Locale.Tr "repo.archive.nocomment"}}
</div>
{{else}}
<div class="ui warning message">

View file

@ -236,7 +236,7 @@ func TestBlockActions(t *testing.T) {
// Ensures that comment creation on doer's owned repositories and doer's
// posted issues are blocked.
t.Run("Comment creation", func(t *testing.T) {
expectedMessage := locale.Tr("repo.issues.comment.blocked_by_user")
expectedMessage := locale.Tr("repo.comment.blocked_by_user")
t.Run("Blocked by repository owner", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()