@@ -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,13 +68,14 @@ 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
7578
76- // TODO: i18n templates?
7779 if err := bodyTemplates .ExecuteTemplate (& content , string (tpl ), data ); err != nil {
7880 log .Error ("Template: %v" , err )
7981 return
@@ -104,13 +106,14 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {
104106 "ActiveCodeLives" : timeutil .MinutesToFriendly (setting .Service .ActiveCodeLives , locale .Language ()),
105107 "Code" : u .GenerateEmailActivateCode (email .Email ),
106108 "Email" : email .Email ,
107- "i18n" : locale ,
108109 "Language" : locale .Language (),
110+ // helper
111+ "i18n" : locale ,
112+ "Str2html" : templates .Str2html ,
109113 }
110114
111115 var content bytes.Buffer
112116
113- // TODO: i18n templates?
114117 if err := bodyTemplates .ExecuteTemplate (& content , string (mailAuthActivateEmail ), data ); err != nil {
115118 log .Error ("Template: %v" , err )
116119 return
@@ -129,13 +132,14 @@ func SendRegisterNotifyMail(u *models.User) {
129132 data := map [string ]interface {}{
130133 "DisplayName" : u .DisplayName (),
131134 "Username" : u .Name ,
132- "i18n" : locale ,
133135 "Language" : locale .Language (),
136+ // helper
137+ "i18n" : locale ,
138+ "Str2html" : templates .Str2html ,
134139 }
135140
136141 var content bytes.Buffer
137142
138- // TODO: i18n templates?
139143 if err := bodyTemplates .ExecuteTemplate (& content , string (mailAuthRegisterNotify ), data ); err != nil {
140144 log .Error ("Template: %v" , err )
141145 return
@@ -157,13 +161,14 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) {
157161 "Subject" : subject ,
158162 "RepoName" : repoName ,
159163 "Link" : repo .HTMLURL (),
160- "i18n" : locale ,
161164 "Language" : locale .Language (),
165+ // helper
166+ "i18n" : locale ,
167+ "Str2html" : templates .Str2html ,
162168 }
163169
164170 var content bytes.Buffer
165171
166- // TODO: i18n templates?
167172 if err := bodyTemplates .ExecuteTemplate (& content , string (mailNotifyCollaborator ), data ); err != nil {
168173 log .Error ("Template: %v" , err )
169174 return
@@ -239,12 +244,13 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
239244 "ActionType" : actType ,
240245 "ActionName" : actName ,
241246 "ReviewComments" : reviewComments ,
242- "i18n" : locale ,
243247 "Language" : locale .Language (),
248+ // helper
249+ "i18n" : locale ,
250+ "Str2html" : templates .Str2html ,
244251 }
245252
246253 var mailSubject bytes.Buffer
247- // TODO: i18n templates?
248254 if err := subjectTemplates .ExecuteTemplate (& mailSubject , string (tplName ), mailMeta ); err == nil {
249255 subject = sanitizeSubject (mailSubject .String ())
250256 if subject == "" {
@@ -260,7 +266,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
260266
261267 var mailBody bytes.Buffer
262268
263- // TODO: i18n templates?
264269 if err := bodyTemplates .ExecuteTemplate (& mailBody , string (tplName ), mailMeta ); err != nil {
265270 log .Error ("ExecuteTemplate [%s]: %v" , string (tplName )+ "/body" , err )
266271 }
0 commit comments