Skip to content

Commit f8d0987

Browse files
committed
localize activate_account & activate_email
1 parent 6667f52 commit f8d0987

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

options/locale/locale_en-US.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,15 @@ password_pwned_err = Could not complete request to HaveIBeenPwned
318318
319319
[mail]
320320
activate_account = Please activate your account
321+
activate_account.title = %s, please activate your account
322+
activate_account.body = <p>Hi <b>%[1]s</b>, thanks for registering at %[5]s!</p><br><p>Please click the following link to activate your account within <b>%[2]s</b>:</p><br><p><a href="%[3]s">%[3]s</a></p><br><p>Not working? Try copying and pasting it to your browser.</p><br><p>© <a target="_blank" rel="noopener noreferrer" href="%[4]s">%[5]s</a></p>
323+
324+
325+
activate_email.title = %s, please verify your e-mail address
326+
activate_email.body = <p>Hi <b>%[1]s</b>,</p><br><p>Please click the following link to verify your email address within <b>%[2]s</b>:</p><br><p><a href="%[3]s">%[3]s</a></p><br><p>Not working? Try copying and pasting it to your browser.</p><br><p>© <a target="_blank" rel="noopener noreferrer" href="%[4]s">%[5]s</a></p>
321327
activate_email = Verify your email address
328+
329+
322330
reset_password = Recover your account
323331
register_success = Registration successful
324332
register_notify = Welcome to Gitea

services/mailer/mail.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"code.gitea.io/gitea/modules/markup"
2323
"code.gitea.io/gitea/modules/markup/markdown"
2424
"code.gitea.io/gitea/modules/setting"
25+
"code.gitea.io/gitea/modules/templates"
2526
"code.gitea.io/gitea/modules/timeutil"
2627
"code.gitea.io/gitea/modules/translation"
2728

@@ -67,8 +68,10 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje
6768
"ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, language),
6869
"ResetPwdCodeLives": timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, language),
6970
"Code": code,
70-
"i18n": locale,
7171
"Language": locale.Language(),
72+
// helper
73+
"i18n": locale,
74+
"Str2html": templates.Str2html,
7275
}
7376

7477
var content bytes.Buffer
@@ -104,8 +107,10 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {
104107
"ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, locale.Language()),
105108
"Code": u.GenerateEmailActivateCode(email.Email),
106109
"Email": email.Email,
107-
"i18n": locale,
108110
"Language": locale.Language(),
111+
// helper
112+
"i18n": locale,
113+
"Str2html": templates.Str2html,
109114
}
110115

111116
var content bytes.Buffer
@@ -129,8 +134,10 @@ func SendRegisterNotifyMail(u *models.User) {
129134
data := map[string]interface{}{
130135
"DisplayName": u.DisplayName(),
131136
"Username": u.Name,
132-
"i18n": locale,
133137
"Language": locale.Language(),
138+
// helper
139+
"i18n": locale,
140+
"Str2html": templates.Str2html,
134141
}
135142

136143
var content bytes.Buffer
@@ -157,8 +164,10 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) {
157164
"Subject": subject,
158165
"RepoName": repoName,
159166
"Link": repo.HTMLURL(),
160-
"i18n": locale,
161167
"Language": locale.Language(),
168+
// helper
169+
"i18n": locale,
170+
"Str2html": templates.Str2html,
162171
}
163172

164173
var content bytes.Buffer
@@ -239,8 +248,10 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
239248
"ActionType": actType,
240249
"ActionName": actName,
241250
"ReviewComments": reviewComments,
242-
"i18n": locale,
243251
"Language": locale.Language(),
252+
// helper
253+
"i18n": locale,
254+
"Str2html": templates.Str2html,
244255
}
245256

246257
var mailSubject bytes.Buffer

templates/mail/auth/activate.tmpl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.DisplayName}}, please activate your account</title>
5+
<title>{{.i18n.Tr "mail.activate_account.title" .DisplayName}}</title>
66
</head>
77

8+
{{ $activate_url := printf "%suser/activate?code=%s" AppUrl .Code}}
89
<body>
9-
<p>Hi <b>{{.DisplayName}}</b>, thanks for registering at {{AppName}}!</p>
10-
<p>Please click the following link to activate your account within <b>{{.ActiveCodeLives}}</b>:</p>
11-
<p><a href="{{AppUrl}}user/activate?code={{.Code}}">{{AppUrl}}user/activate?code={{.Code}}</a></p>
12-
<p>Not working? Try copying and pasting it to your browser.</p>
13-
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>
10+
{{.i18n.Tr "mail.activate_account.body" .DisplayName .ActiveCodeLives $activate_url AppUrl AppName | Str2html}}
1411
</body>
1512
</html>

templates/mail/auth/activate_email.tmpl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
<html>
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>{{.DisplayName}}, please verify your e-mail address</title>
5+
<title>{{.i18n.Tr "mail.activate_email.title" .DisplayName}}</title>
66
</head>
77

8+
{{ $activate_url := printf "%suser/activate_email?code=%s&email=%s" AppUrl .Code .Email}}
89
<body>
9-
<p>Hi <b>{{.DisplayName}}</b>,</p>
10-
<p>Please click the following link to verify your email address within <b>{{.ActiveCodeLives}}</b>:</p>
11-
<p><a href="{{AppUrl}}user/activate_email?code={{.Code}}&email={{.Email}}">{{AppUrl}}user/activate_email?code={{.Code}}&email={{.Email}}</a></p>
12-
<p>Not working? Try copying and pasting it to your browser.</p>
13-
<p>© <a target="_blank" rel="noopener noreferrer" href="{{AppUrl}}">{{AppName}}</a></p>
10+
{{.i18n.Tr "mail.activate_email.body" .DisplayName .ActiveCodeLives $activate_url AppUrl AppName | Str2html}}
1411
</body>
1512
</html>

0 commit comments

Comments
 (0)