Skip to content

Commit 8798e3a

Browse files
authored
Use TrN helper for email templates (#16425)
* Add TrN helper * use TrN * a nit
1 parent 8464fa1 commit 8798e3a

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ issue_assigned.issue = @%[1]s assigned you to the issue %[2]s in repository %[3]
350350
351351
issue.x_mentioned_you = <b>@%s</b> mentioned you:
352352
issue.action.force_push = <b>%[1]s</b> force-pushed the <b>%[2]s</b> from %[3]s to %[4]s.
353-
issue.action.push_1 = <b>@%[1]s</b> pushed 1 commit to %[2]s
353+
issue.action.push_1 = <b>@%[1]s</b> pushed %[3]d commit to %[2]s
354354
issue.action.push_n = <b>@%[1]s</b> pushed %[3]d commits to %[2]s
355355
issue.action.close = <b>@%[1]s</b> closed #%[2]d.
356356
issue.action.reopen = <b>@%[1]s</b> reopened #%[2]d.

services/mailer/mail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje
7272
// helper
7373
"i18n": locale,
7474
"Str2html": templates.Str2html,
75+
"TrN": templates.TrN,
7576
}
7677

7778
var content bytes.Buffer
@@ -110,6 +111,7 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {
110111
// helper
111112
"i18n": locale,
112113
"Str2html": templates.Str2html,
114+
"TrN": templates.TrN,
113115
}
114116

115117
var content bytes.Buffer
@@ -136,6 +138,7 @@ func SendRegisterNotifyMail(u *models.User) {
136138
// helper
137139
"i18n": locale,
138140
"Str2html": templates.Str2html,
141+
"TrN": templates.TrN,
139142
}
140143

141144
var content bytes.Buffer
@@ -165,6 +168,7 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) {
165168
// helper
166169
"i18n": locale,
167170
"Str2html": templates.Str2html,
171+
"TrN": templates.TrN,
168172
}
169173

170174
var content bytes.Buffer
@@ -248,6 +252,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
248252
// helper
249253
"i18n": locale,
250254
"Str2html": templates.Str2html,
255+
"TrN": templates.TrN,
251256
}
252257

253258
var mailSubject bytes.Buffer

services/mailer/mail_release.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func mailNewRelease(lang string, tos []string, rel *models.Release) {
6868
// helper
6969
"i18n": locale,
7070
"Str2html": templates.Str2html,
71+
"TrN": templates.TrN,
7172
}
7273

7374
var mailBody bytes.Buffer

services/mailer/mail_repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *models.User,
6363
// helper
6464
"i18n": locale,
6565
"Str2html": templates.Str2html,
66+
"TrN": templates.TrN,
6667
}
6768

6869
if err := bodyTemplates.ExecuteTemplate(&content, string(mailRepoTransferNotify), data); err != nil {

templates/mail/issue/default.tmpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030

3131
{{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}}
3232
{{else}}
33-
{{if eq .Comment.Commits.Len 1}}
34-
{{.i18n.Tr "mail.issue.action.push_1" .Doer.Name .Comment.Issue.PullRequest.HeadBranch | Str2html}}
35-
{{else}}
36-
{{.i18n.Tr "mail.issue.action.push_n" .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}}
37-
{{end}}
33+
{{.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}}
3834
{{end}}
3935
</p>
4036
{{end}}

0 commit comments

Comments
 (0)