From f8d0987905ee26bce549c08deb1a13f5412e25f7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 19 Jun 2021 03:35:29 +0200 Subject: [PATCH 01/18] localize activate_account & activate_email --- options/locale/locale_en-US.ini | 8 ++++++++ services/mailer/mail.go | 21 ++++++++++++++++----- templates/mail/auth/activate.tmpl | 9 +++------ templates/mail/auth/activate_email.tmpl | 9 +++------ 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2fa70679d8281..796e88724ba43 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -318,7 +318,15 @@ password_pwned_err = Could not complete request to HaveIBeenPwned [mail] activate_account = Please activate your account +activate_account.title = %s, please activate your account +activate_account.body =
Hi %[1]s, thanks for registering at %[5]s!
Please click the following link to activate your account within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
+ + +activate_email.title = %s, please verify your e-mail address +activate_email.body =Hi %[1]s,
Please click the following link to verify your email address within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
activate_email = Verify your email address + + reset_password = Recover your account register_success = Registration successful register_notify = Welcome to Gitea diff --git a/services/mailer/mail.go b/services/mailer/mail.go index ea3edaa90db6e..b0484a9a0c8d0 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,8 +68,10 @@ 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 @@ -104,8 +107,10 @@ 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 @@ -129,8 +134,10 @@ 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 @@ -157,8 +164,10 @@ 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 @@ -239,8 +248,10 @@ 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 diff --git a/templates/mail/auth/activate.tmpl b/templates/mail/auth/activate.tmpl index 37fdbd7c7ce40..273ec4b4c8432 100644 --- a/templates/mail/auth/activate.tmpl +++ b/templates/mail/auth/activate.tmpl @@ -2,14 +2,11 @@ -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.body" .DisplayName .ActiveCodeLives $activate_url AppUrl AppName | Str2html}} diff --git a/templates/mail/auth/activate_email.tmpl b/templates/mail/auth/activate_email.tmpl index ebcaa0ee79e02..2521273986eb2 100644 --- a/templates/mail/auth/activate_email.tmpl +++ b/templates/mail/auth/activate_email.tmpl @@ -2,14 +2,11 @@ -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.activate_email.body" .DisplayName .ActiveCodeLives $activate_url AppUrl AppName | Str2html}} From de006727278c491e38d3452b2db1c68733ec2a1b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 19 Jun 2021 03:50:33 +0200 Subject: [PATCH 02/18] register_notify --- options/locale/locale_en-US.ini | 7 ++++--- templates/mail/auth/register_notify.tmpl | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 796e88724ba43..baefeec749054 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -321,15 +321,16 @@ activate_account = Please activate your account activate_account.title = %s, please activate your account activate_account.body =Hi %[1]s, thanks for registering at %[5]s!
Please click the following link to activate your account within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
- +activate_email = Verify your email address activate_email.title = %s, please verify your e-mail address activate_email.body =Hi %[1]s,
Please click the following link to verify your email address within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
-activate_email = Verify your email address +register_notify = Welcome to Gitea +register_notify.title = %[1]s, welcome to %[2]s +register_notify.body =Hi %[1]s, this is your registration confirmation email for %[4]s!
You can now login via username: %[2]s.
If this account has been created for you, please set your password first.
© %[4]s
reset_password = Recover your account register_success = Registration successful -register_notify = Welcome to Gitea release.new.subject = %s in %s released diff --git a/templates/mail/auth/register_notify.tmpl b/templates/mail/auth/register_notify.tmpl index ea1857030abaf..1eb6df8e28349 100644 --- a/templates/mail/auth/register_notify.tmpl +++ b/templates/mail/auth/register_notify.tmpl @@ -2,14 +2,10 @@ -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.register_notify.body" .DisplayName .Username AppUrl AppName | Str2html}} From 41d6eb2dfb303a807991762e3b43c24f191e2479 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 19 Jun 2021 03:56:37 +0200 Subject: [PATCH 03/18] reset_password --- options/locale/locale_en-US.ini | 3 +++ templates/mail/auth/reset_passwd.tmpl | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index baefeec749054..5c9c9662d1195 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -330,6 +330,9 @@ register_notify.title = %[1]s, welcome to %[2]s register_notify.body =Hi %[1]s, this is your registration confirmation email for %[4]s!
You can now login via username: %[2]s.
If this account has been created for you, please set your password first.
© %[4]s
reset_password = Recover your account +reset_password.title = %s, you have requested to recover your account +reset_password.body =Hi %[1]s,
Please click the following link to recover your account within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
+ register_success = Registration successful release.new.subject = %s in %s released diff --git a/templates/mail/auth/reset_passwd.tmpl b/templates/mail/auth/reset_passwd.tmpl index e01d57cea25e6..0b4d6ef3ffc46 100644 --- a/templates/mail/auth/reset_passwd.tmpl +++ b/templates/mail/auth/reset_passwd.tmpl @@ -2,15 +2,11 @@ -Hi {{.DisplayName}},
-Please click the following link to recover your account within {{.ResetPwdCodeLives}}:
- -{{AppUrl}}user/recover_account?code={{.Code}}
-Not working? Try copying and pasting it to your browser.
- + {{.i18n.Tr "mail.reset_password.body" .DisplayName .ResetPwdCodeLives $recover_url AppUrl AppName | Str2html}} From 5af316d0800c7b4ea0473808380c915736bf9fa5 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 20 Jun 2021 13:48:57 +0200 Subject: [PATCH 04/18] issue_assigned --- options/locale/locale_en-US.ini | 5 +++++ templates/mail/issue/assigned.tmpl | 10 ++++++++-- templates/mail/issue/default.tmpl | 2 +- templates/mail/notify/collaborator.tmpl | 2 +- templates/mail/notify/repo_transfer.tmpl | 2 +- templates/mail/release.tmpl | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 5c9c9662d1195..383db3e7d9ad3 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -317,6 +317,8 @@ password_pwned = The password you chose is on a View it on %[2]s. + activate_account = Please activate your account activate_account.title = %s, please activate your account activate_account.body =Hi %[1]s, thanks for registering at %[5]s!
Please click the following link to activate your account within %[2]s:
Not working? Try copying and pasting it to your browser.
© %[5]s
@@ -335,6 +337,9 @@ reset_password.body =Hi %[1]s,
Please click the following l register_success = Registration successful +issue_assigned.pull = @%[1]s assigned you to the pull request #@%[3]d in repository %[4]s. +issue_assigned.issue = @%[1]s assigned you to the issue #@%[3]d in repository %[4]s. + release.new.subject = %s in %s released repo.transfer.subject_to = %s would like to transfer "%s" to %s diff --git a/templates/mail/issue/assigned.tmpl b/templates/mail/issue/assigned.tmpl index 5b0d2526f1252..66f2d1f36e99e 100644 --- a/templates/mail/issue/assigned.tmpl +++ b/templates/mail/issue/assigned.tmpl @@ -9,12 +9,18 @@
-@{{.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 .Issue.Index .Repo | Str2html}} + {{else}} + {{.i18n.Tr "mail.issue_assigned.issue" .Doer.Name .Link .Issue.Index .Repo | Str2html}} + {{end}} +
diff --git a/templates/mail/issue/default.tmpl b/templates/mail/issue/default.tmpl index 4b492dad8ad1e..50f38e0ca7e57 100644 --- a/templates/mail/issue/default.tmpl +++ b/templates/mail/issue/default.tmpl @@ -85,7 +85,7 @@
---
- View it on {{AppName}}.
+ {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}}