diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2fa70679d..ded76272b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -317,19 +317,64 @@ password_pwned = The password you chose is on a set your password first. + +reset_password = Recover your account +reset_password.title = %s, you have requested to recover your account +reset_password.text = Please click the following link to recover your account within %s: + +register_success = Registration successful + +issue_assigned.pull = @%[1]s assigned you to the pull request %[2]s in repository %[3]s. +issue_assigned.issue = @%[1]s assigned you to the issue %[2]s in repository %[3]s. + +issue.x_mentioned_you = @%s mentioned you: +issue.action.force_push = %[1]s force-pushed the %[2]s from %[3]s to %[4]s. +issue.action.push_1 = @%[1]s pushed 1 commit to %[2]s +issue.action.push_n = @%[1]s pushed %[3]d commits to %s: %[2]s +issue.action.close = @%[1]s closed #%[2]d. +issue.action.reopen = @%[1]s reopened #%[2]d. +issue.action.merge = @%[1]s merged #%[2]d into #%[3]s. +issue.action.approve = @%[1]s approved this pull request. +issue.action.reject = @%[1]s requested changes on this pull request. +issue.action.review = @%[1]s commented on this pull request. +issue.action.review_dismissed = @%[1]s dismissed last review from %[2]s for this pull request. +issue.action.ready_for_review = @%[1]s marked this pull request ready for review. +issue.action.new = Created #%[2]d. +issue.in_tree_path = In %s: release.new.subject = %s in %s released +release.new.text = @%[1]s released %[2]s in %[3]s +release.title = Title: %s +release.note = Note: +release.downloads = Downloads: +release.download.zip = Source Code (ZIP) +release.download.targz = Source Code (TAR.GZ) repo.transfer.subject_to = %s would like to transfer "%s" to %s repo.transfer.subject_to_you = %s would like to transfer "%s" to you repo.transfer.to_you = you +repo.transfer.body = To accept or reject it visit %s or just ignore it. repo.collaborator.added.subject = %s added you to %s +repo.collaborator.added.text = You have been added as a collaborator of repository: [modal] yes = Yes diff --git a/services/mailer/mail.go b/services/mailer/mail.go index fdc070e4b..7494d04f2 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/translation" @@ -67,13 +68,14 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, language), "ResetPwdCodeLives": timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, language), "Code": code, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(tpl), data); err != nil { log.Error("Template: %v", err) return @@ -104,13 +106,14 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) { "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, locale.Language()), "Code": u.GenerateEmailActivateCode(email.Email), "Email": email.Email, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthActivateEmail), data); err != nil { log.Error("Template: %v", err) return @@ -129,13 +132,14 @@ func SendRegisterNotifyMail(u *models.User) { data := map[string]interface{}{ "DisplayName": u.DisplayName(), "Username": u.Name, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthRegisterNotify), data); err != nil { log.Error("Template: %v", err) return @@ -157,13 +161,14 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) { "Subject": subject, "RepoName": repoName, "Link": repo.HTMLURL(), - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailNotifyCollaborator), data); err != nil { log.Error("Template: %v", err) return @@ -239,12 +244,13 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient "ActionType": actType, "ActionName": actName, "ReviewComments": reviewComments, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var mailSubject bytes.Buffer - // TODO: i18n templates? if err := subjectTemplates.ExecuteTemplate(&mailSubject, string(tplName), mailMeta); err == nil { subject = sanitizeSubject(mailSubject.String()) if subject == "" { @@ -260,7 +266,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient var mailBody bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&mailBody, string(tplName), mailMeta); err != nil { log.Error("ExecuteTemplate [%s]: %v", string(tplName)+"/body", err) } diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go index 1e12fe13a..ff008be1d 100644 --- a/services/mailer/mail_release.go +++ b/services/mailer/mail_release.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/translation" ) @@ -63,13 +64,14 @@ func mailNewRelease(lang string, tos []string, rel *models.Release) { mailMeta := map[string]interface{}{ "Release": rel, "Subject": subject, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var mailBody bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&mailBody, string(tplNewReleaseMail), mailMeta); err != nil { log.Error("ExecuteTemplate [%s]: %v", string(tplNewReleaseMail)+"/body", err) return diff --git a/services/mailer/mail_repo.go b/services/mailer/mail_repo.go index c742101ee..5ef67b7c6 100644 --- a/services/mailer/mail_repo.go +++ b/services/mailer/mail_repo.go @@ -9,6 +9,7 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/translation" ) @@ -57,12 +58,13 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *models.User, "Repo": repo.FullName(), "Link": repo.HTMLURL(), "Subject": subject, - "i18n": locale, "Language": locale.Language(), "Destination": destination, + // helper + "i18n": locale, + "Str2html": templates.Str2html, } - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailRepoTransferNotify), data); err != nil { return err } diff --git a/templates/mail/auth/activate.tmpl b/templates/mail/auth/activate.tmpl index 37fdbd7c7..1f0204157 100644 --- a/templates/mail/auth/activate.tmpl +++ b/templates/mail/auth/activate.tmpl @@ -2,14 +2,15 @@
-Hi {{.DisplayName}}, thanks for registering at {{AppName}}!
-Please click the following link to activate your account within {{.ActiveCodeLives}}:
-{{AppUrl}}user/activate?code={{.Code}}
-Not working? Try copying and pasting it to your browser.
+{{.i18n.Tr "mail.activate_account.test_1" .DisplayName AppName | Str2html}}
{{.i18n.Tr "mail.activate_account.test_2" .ActiveCodeLives | Str2html}}
{{.i18n.Tr "mail.link_not_working_do_paste" .DisplayName AppName | Str2html}}
+ diff --git a/templates/mail/auth/activate_email.tmpl b/templates/mail/auth/activate_email.tmpl index ebcaa0ee7..27cff3ba4 100644 --- a/templates/mail/auth/activate_email.tmpl +++ b/templates/mail/auth/activate_email.tmpl @@ -2,14 +2,15 @@ -Hi {{.DisplayName}},
-Please click the following link to verify your email address within {{.ActiveCodeLives}}:
-{{AppUrl}}user/activate_email?code={{.Code}}&email={{.Email}}
-Not working? Try copying and pasting it to your browser.
+{{.i18n.Tr "mail.hi_user_x" .DisplayName | Str2html}}
{{.i18n.Tr "mail.activate_email.text" .ActiveCodeLives | Str2html}}
{{.i18n.Tr "mail.link_not_working_do_paste" .DisplayName AppName | Str2html}}
+ diff --git a/templates/mail/auth/register_notify.tmpl b/templates/mail/auth/register_notify.tmpl index ea1857030..e1ab97b76 100644 --- a/templates/mail/auth/register_notify.tmpl +++ b/templates/mail/auth/register_notify.tmpl @@ -2,14 +2,16 @@ -Hi {{.DisplayName}}, this is your registration confirmation email for {{AppName}}!
-You can now login via username: {{.Username}}.
- -If this account has been created for you, please set your password first.
+{{.i18n.Tr "mail.hi_user_x" .DisplayName | Str2html}}
{{.i18n.Tr "mail.register_notify.text_1" AppName}}
{{.i18n.Tr "mail.register_notify.text_2" .Username}}
{{.i18n.Tr "mail.register_notify.text_3" $set_pwd_url | Str2html}}
Hi {{.DisplayName}},
-Please click the following link to recover your account within {{.ResetPwdCodeLives}}:
+{{.i18n.Tr "mail.hi_user_x" .DisplayName | Str2html}}
{{.i18n.Tr "mail.reset_password.text" .ResetPwdCodeLives | Str2html}}
{{.i18n.Tr "mail.link_not_working_do_paste" .DisplayName AppName | Str2html}}
-{{AppUrl}}user/recover_account?code={{.Code}}
-Not working? Try copying and pasting it to your browser.
diff --git a/templates/mail/issue/assigned.tmpl b/templates/mail/issue/assigned.tmpl index 5b0d2526f..61e4a44f0 100644 --- a/templates/mail/issue/assigned.tmpl +++ b/templates/mail/issue/assigned.tmpl @@ -8,13 +8,21 @@@{{.Doer.Name}} assigned you to the {{if .IsPull}}pull request{{else}}issue{{end}} #{{.Issue.Index}} in repository {{.Repo}}.
++ {{if .IsPull}} + {{.i18n.Tr "mail.issue_assigned.pull" .Doer.Name $link $repo_url | Str2html}} + {{else}} + {{.i18n.Tr "mail.issue_assigned.issue" .Doer.Name $link $repo_url | Str2html}} + {{end}} +
diff --git a/templates/mail/issue/default.tmpl b/templates/mail/issue/default.tmpl index 02832c7e4..61fe02037 100644 --- a/templates/mail/issue/default.tmpl +++ b/templates/mail/issue/default.tmpl @@ -16,55 +16,57 @@ - {{if .IsMention}}@{{.Doer.Name}} mentioned you:
{{end}} + {{if .IsMention}}{{.i18n.Tr "mail.issue.x_mentioned_you" .Doer.Name | Str2html}}
{{end}} {{if eq .ActionName "push"}}- {{.Doer.Name}} {{if .Comment.IsForcePush}} - {{ $oldCommitLink:= printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.OldCommit}} - {{ $newCommitLink:= printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.NewCommit}} - force-pushed the {{.Comment.Issue.PullRequest.HeadBranch}} from - {{ShortSha .Comment.OldCommit}} - to - {{ShortSha .Comment.NewCommit}}. + {{$oldCommitUrl := printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.OldCommit}} + {{$oldShortSha := ShortSha .Comment.OldCommit}} + {{$oldCommitLink := printf "%[2]s" $oldCommitUrl $oldShortSha}} + + {{$newCommitUrl := printf "%s%s/%s/commit/%s" AppUrl .Comment.Issue.PullRequest.BaseRepo.OwnerName .Comment.Issue.PullRequest.BaseRepo.Name .Comment.NewCommit}} + {{$newShortSha := ShortSha .Comment.NewCommit}} + {{$newCommitLink := printf "%[2]s" $newCommitUrl $newShortSha}} + + {{.i18n.Tr "mail.issue.action.force_push" .Doer.Name .Comment.Issue.PullRequest.HeadBranch $oldCommitLink $newCommitLink | Str2html}} {{else}} {{if eq .Comment.Commits.Len 1}} - {{printf "pushed 1 commit to %s:" .Comment.Issue.PullRequest.HeadBranch}} + {{.i18n.Tr "mail.issue.action.push_1" .Doer.Name .Comment.Issue.PullRequest.HeadBranch | Str2html}} {{else}} - {{printf "pushed %d commits to %s:" .Comment.Commits.Len .Comment.Issue.PullRequest.HeadBranch}} + {{.i18n.Tr "mail.issue.action.push_1" .Doer.Name .Comment.Issue.PullRequest.HeadBranch .Comment.Commits.Len | Str2html}} {{end}} {{end}}
{{end}}{{if eq .ActionName "close"}} - Closed #{{.Issue.Index}}. + {{.i18n.Tr "mail.issue.action.close" .Doer.Name .Issue.Index | Str2html}} {{else if eq .ActionName "reopen"}} - Reopened #{{.Issue.Index}}. + {{.i18n.Tr "mail.issue.action.reopen" .Doer.Name .Issue.Index | Str2html}} {{else if eq .ActionName "merge"}} - Merged #{{.Issue.Index}} into {{.Issue.PullRequest.BaseBranch}}. + {{.i18n.Tr "mail.issue.action.merge" .Doer.Name .Issue.Index .Issue.PullRequest.BaseBranch | Str2html}} {{else if eq .ActionName "approve"}} - @{{.Doer.Name}} approved this pull request. + {{.i18n.Tr "mail.issue.action.approve" .Doer.Name | Str2html}} {{else if eq .ActionName "reject"}} - @{{.Doer.Name}} requested changes on this pull request. + {{.i18n.Tr "mail.issue.action.reject" .Doer.Name | Str2html}} {{else if eq .ActionName "review"}} - @{{.Doer.Name}} commented on this pull request. + {{.i18n.Tr "mail.issue.action.review" .Doer.Name | Str2html}} {{else if eq .ActionName "review_dismissed"}} - @{{.Doer.Name}} dismissed last review from {{.Comment.Review.Reviewer.Name}} for this pull request. + {{.i18n.Tr "mail.issue.action.review_dismissed" .Doer.Name .Comment.Review.Reviewer.Name | Str2html}} {{else if eq .ActionName "ready_for_review"}} - @{{.Doer.Name}} marked this pull request ready for review. + {{.i18n.Tr "mail.issue.action.ready_for_review" .Doer.Name | Str2html}} {{end}} {{- if eq .Body ""}} {{if eq .ActionName "new"}} - Created #{{.Issue.Index}}. + {{.i18n.Tr "mail.issue.action.new" .Doer.Name .Issue.Index | Str2html}} {{end}} {{else}} {{.Body | Str2html}} {{end -}} {{- range .ReviewComments}}
{{.Patch}}
---
- View it on {{AppName}}.
+ {{.i18n.Tr "mail.view_it_on" AppName}}.
You have been added as a collaborator of repository: {{.RepoName}}
{{.i18n.Tr "mail.repo.collaborator.added.text"}} {{.RepoName}}
{{.Subject}}. - To accept or reject it visit {{.Repo}} or just ignore it. + {{.i18n.Tr "mail.repo.transfer.body" $url | Str2html}}
---
- View it on {{AppName}}.
+ {{.i18n.Tr "mail.view_it_on" AppName}}.