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 2fa70679d828..796e88724ba4 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:


%[3]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:


%[3]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 ea3edaa90db6..b0484a9a0c8d 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 37fdbd7c7ce4..273ec4b4c843 100644 --- a/templates/mail/auth/activate.tmpl +++ b/templates/mail/auth/activate.tmpl @@ -2,14 +2,11 @@ - {{.DisplayName}}, please activate your account + {{.i18n.Tr "mail.activate_account.title" .DisplayName}} +{{ $activate_url := printf "%suser/activate?code=%s" AppUrl .Code}} -

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.

-

© {{AppName}}

+ {{.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 ebcaa0ee79e0..2521273986eb 100644 --- a/templates/mail/auth/activate_email.tmpl +++ b/templates/mail/auth/activate_email.tmpl @@ -2,14 +2,11 @@ - {{.DisplayName}}, please verify your e-mail address + {{.i18n.Tr "mail.activate_email.title" .DisplayName}} +{{ $activate_url := printf "%suser/activate_email?code=%s&email=%s" AppUrl .Code .Email}} -

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.

-

© {{AppName}}

+ {{.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 796e88724ba4..baefeec74905 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:


%[3]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:


%[3]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.


%[3]suser/login


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 ea1857030aba..1eb6df8e2834 100644 --- a/templates/mail/auth/register_notify.tmpl +++ b/templates/mail/auth/register_notify.tmpl @@ -2,14 +2,10 @@ - {{.DisplayName}}, welcome to {{AppName}} + {{.i18n.Tr "mail.register_notify.title" .DisplayName AppName}} -

Hi {{.DisplayName}}, this is your registration confirmation email for {{AppName}}!

-

You can now login via username: {{.Username}}.

-

{{AppUrl}}user/login

-

If this account has been created for you, please set your password first.

-

© {{AppName}}

+ {{.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 baefeec74905..5c9c9662d119 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.


%[3]suser/login


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:



%[3]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 e01d57cea25e..0b4d6ef3ffc4 100644 --- a/templates/mail/auth/reset_passwd.tmpl +++ b/templates/mail/auth/reset_passwd.tmpl @@ -2,15 +2,11 @@ - {{.DisplayName}}, you have requested to recover your account + {{.i18n.Tr "mail.reset_password.title" .DisplayName}} +{{ $recover_url := printf "%suser/recover_account?code=%s" AppUrl .Code}} -

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.

-

© {{AppName}}

+ {{.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 5c9c9662d119..383db3e7d9ad 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:


%[3]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 5b0d2526f125..66f2d1f36e99 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 4b492dad8ad1..50f38e0ca7e5 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}}

diff --git a/templates/mail/notify/collaborator.tmpl b/templates/mail/notify/collaborator.tmpl index 19a24310233d..180729a4d8b6 100644 --- a/templates/mail/notify/collaborator.tmpl +++ b/templates/mail/notify/collaborator.tmpl @@ -14,7 +14,7 @@

---
- View it on {{AppName}}. + {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}}

diff --git a/templates/mail/notify/repo_transfer.tmpl b/templates/mail/notify/repo_transfer.tmpl index e0dca8869d66..216a1c1c9ca1 100644 --- a/templates/mail/notify/repo_transfer.tmpl +++ b/templates/mail/notify/repo_transfer.tmpl @@ -11,7 +11,7 @@

---
- View it on {{AppName}}. + {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}}

diff --git a/templates/mail/release.tmpl b/templates/mail/release.tmpl index 7829bce24351..51398df05d74 100644 --- a/templates/mail/release.tmpl +++ b/templates/mail/release.tmpl @@ -51,7 +51,7 @@

---
- View it on {{AppName}}. + {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}}

From 7cf1b86b1ec247b57827a674b60ebd7feca40761 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 20 Jun 2021 13:51:59 +0200 Subject: [PATCH 05/18] repo_transfer --- options/locale/locale_en-US.ini | 1 + templates/mail/notify/repo_transfer.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 383db3e7d9ad..97afaaf3a141 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -345,6 +345,7 @@ release.new.subject = %s in %s released 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 %[2]s or just ignore it. repo.collaborator.added.subject = %s added you to %s diff --git a/templates/mail/notify/repo_transfer.tmpl b/templates/mail/notify/repo_transfer.tmpl index 216a1c1c9ca1..004358d25342 100644 --- a/templates/mail/notify/repo_transfer.tmpl +++ b/templates/mail/notify/repo_transfer.tmpl @@ -7,7 +7,7 @@

{{.Subject}}. - To accept or reject it visit {{.Repo}} or just ignore it. + {{.i18n.Tr "mail.repo.transfer.body" .Link .Repo | Str2html}}

---
From 148b46658606e31957466afa0f54fc37b53fad52 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 20 Jun 2021 13:54:22 +0200 Subject: [PATCH 06/18] collaborator --- options/locale/locale_en-US.ini | 1 + templates/mail/notify/collaborator.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 97afaaf3a141..72626866dd41 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -348,6 +348,7 @@ repo.transfer.to_you = you repo.transfer.body = To accept or reject it visit %[2]s or just ignore it. repo.collaborator.added.subject = %s added you to %s +repo.collaborator.added.body =

You have been added as a collaborator of repository: %[1]s

[modal] yes = Yes diff --git a/templates/mail/notify/collaborator.tmpl b/templates/mail/notify/collaborator.tmpl index 180729a4d8b6..2b31a185f33a 100644 --- a/templates/mail/notify/collaborator.tmpl +++ b/templates/mail/notify/collaborator.tmpl @@ -9,7 +9,7 @@ -

You have been added as a collaborator of repository: {{.RepoName}}

+ {{.i18n.Tr "mail.repo.collaborator.added.body" .RepoName | Str2html}} diff --git a/templates/mail/notify/collaborator.tmpl b/templates/mail/notify/collaborator.tmpl index 2b31a185f33a..f0cfebd355f8 100644 --- a/templates/mail/notify/collaborator.tmpl +++ b/templates/mail/notify/collaborator.tmpl @@ -14,7 +14,7 @@

---
- {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}} + {{.i18n.Tr "mail.view_it_on" AppName}}.

diff --git a/templates/mail/notify/repo_transfer.tmpl b/templates/mail/notify/repo_transfer.tmpl index 004358d25342..adeb30cbd754 100644 --- a/templates/mail/notify/repo_transfer.tmpl +++ b/templates/mail/notify/repo_transfer.tmpl @@ -11,7 +11,7 @@

---
- {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}} + {{.i18n.Tr "mail.view_it_on" AppName}}.

diff --git a/templates/mail/release.tmpl b/templates/mail/release.tmpl index 0e98d9253d3d..6536d7a3eab7 100644 --- a/templates/mail/release.tmpl +++ b/templates/mail/release.tmpl @@ -53,7 +53,7 @@

---
- {{.i18n.Tr "mail.view_it_on_footer" .Link AppName | Str2html}} + {{.i18n.Tr "mail.view_it_on" AppName}}.

From 71748d2e5641e8827ed661969ca668644fd294bb Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 23 Jun 2021 03:34:07 +0200 Subject: [PATCH 15/18] lest html in locale++ --- options/locale/locale_en-US.ini | 10 +++++----- templates/mail/notify/collaborator.tmpl | 2 +- templates/mail/notify/repo_transfer.tmpl | 3 ++- templates/mail/release.tmpl | 11 ++++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d44f131929e0..db388b5c6ca0 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -355,20 +355,20 @@ issue.action.new = Created #%[2]d. issue.in_tree_path = In %s: release.new.subject = %s in %s released -release.new.body = @%[1]s released %[3]s in %[5]s +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) +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 %[2]s or just ignore it. +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.body =

You have been added as a collaborator of repository: %[1]s

+repo.collaborator.added.text = You have been added as a collaborator of repository: [modal] yes = Yes diff --git a/templates/mail/notify/collaborator.tmpl b/templates/mail/notify/collaborator.tmpl index f0cfebd355f8..baa46bafda9d 100644 --- a/templates/mail/notify/collaborator.tmpl +++ b/templates/mail/notify/collaborator.tmpl @@ -9,7 +9,7 @@ - {{.i18n.Tr "mail.repo.collaborator.added.body" .RepoName | Str2html}} +

{{.i18n.Tr "mail.repo.collaborator.added.text"}} {{.RepoName}}