]> source.dussan.org Git - gitea.git/commitdiff
Use TrN helper for email templates (#16425)
author6543 <6543@obermui.de>
Wed, 14 Jul 2021 13:06:09 +0000 (15:06 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Jul 2021 13:06:09 +0000 (15:06 +0200)
* Add TrN helper

* use TrN

* a nit

options/locale/locale_en-US.ini
services/mailer/mail.go
services/mailer/mail_release.go
services/mailer/mail_repo.go
templates/mail/issue/default.tmpl

index 442ae17a9fd813094a6635abad72e828ebb7c5be..0ead1dfd6d087d0e5af7d1d6db6f2f41a147f07c 100644 (file)
@@ -350,7 +350,7 @@ issue_assigned.issue = @%[1]s assigned you to the issue %[2]s in repository %[3]
 
 issue.x_mentioned_you = <b>@%s</b> mentioned you:
 issue.action.force_push = <b>%[1]s</b> force-pushed the <b>%[2]s</b> from %[3]s to %[4]s.
-issue.action.push_1 = <b>@%[1]s</b> pushed 1 commit to %[2]s
+issue.action.push_1 = <b>@%[1]s</b> pushed %[3]d commit to %[2]s
 issue.action.push_n = <b>@%[1]s</b> pushed %[3]d commits to %[2]s
 issue.action.close = <b>@%[1]s</b> closed #%[2]d.
 issue.action.reopen = <b>@%[1]s</b> reopened #%[2]d.
index 7494d04f2b5ce385c2d795cfa40475379f06119b..14512d7d6560eced766173ec3ed489efea22e180 100644 (file)
@@ -72,6 +72,7 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var content bytes.Buffer
@@ -110,6 +111,7 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var content bytes.Buffer
@@ -136,6 +138,7 @@ func SendRegisterNotifyMail(u *models.User) {
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var content bytes.Buffer
@@ -165,6 +168,7 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) {
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var content bytes.Buffer
@@ -248,6 +252,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var mailSubject bytes.Buffer
index ff008be1d8b80ce5903e7af62185f51647d86f4f..f92d3a78fa54d8afbc27201c6eb90a3c0ee56111 100644 (file)
@@ -68,6 +68,7 @@ func mailNewRelease(lang string, tos []string, rel *models.Release) {
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        var mailBody bytes.Buffer
index 5ef67b7c6574aeb3b756e598c08ec6503cfc9bc6..4e629ee5c76b293ffbc2c30c2e0f1d3fbdb708e7 100644 (file)
@@ -63,6 +63,7 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *models.User,
                // helper
                "i18n":     locale,
                "Str2html": templates.Str2html,
+               "TrN":      templates.TrN,
        }
 
        if err := bodyTemplates.ExecuteTemplate(&content, string(mailRepoTransferNotify), data); err != nil {
index f7257f6e6b5cec0594991771c853f9441cbdbebb..071acdcbcfa0cdb7658d813c7ef0cd3a098018d5 100644 (file)
 
                                {{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}}
                        {{else}}
-                               {{if eq .Comment.Commits.Len 1}}
-                                       {{.i18n.Tr "mail.issue.action.push_1" .Doer.Name .Comment.Issue.PullRequest.HeadBranch | Str2html}}
-                               {{else}}
-                                       {{.i18n.Tr "mail.issue.action.push_n" .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}}
-                               {{end}}
+                               {{.i18n.Tr (TrN .i18n.Lang .Comment.Commits.Len "mail.issue.action.push_1" "mail.issue.action.push_n")  .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}}
                        {{end}}
                </p>
        {{end}}