Break HTML blocks to individual strings (#8903)
* Modifying message and templates about mfa_change * Modifying message and templates about password_change * Modify message and template about password_reset * Modify message and template about singin_change * Modify message and template about email_info * Modify message and template about change_username * Modify message about change_email * Add missing props * Add argument * Modify message and template about token_added * Modify messages and template about notification_email * Modify message and template about deactivate_email * Fix style * Remove unused message * Remove br tags * Modify message and code about invite_mail * Add missing message
Этот коммит содержится в:
коммит произвёл
Elias Nahum
родитель
908a682fcf
Коммит
6104c37761
41
app/email.go
41
app/email.go
@@ -55,8 +55,9 @@ func (a *App) SendChangeUsernameEmail(oldUsername, newUsername, email, locale, s
|
||||
bodyPage := a.NewEmailTemplate("email_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.username_change_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.username_change_body.info",
|
||||
bodyPage.Props["Info"] = T("api.templates.username_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "NewUsername": newUsername})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendChangeUsernameEmail", "api.user.send_email_change_username_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -99,8 +100,9 @@ func (a *App) SendEmailChangeEmail(oldEmail, newEmail, locale, siteURL string) *
|
||||
bodyPage := a.NewEmailTemplate("email_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.email_change_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.email_change_body.info",
|
||||
bodyPage.Props["Info"] = T("api.templates.email_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "NewEmail": newEmail})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(oldEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendEmailChangeEmail", "api.user.send_email_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -142,8 +144,9 @@ func (a *App) SendSignInChangeEmail(email, method, locale, siteURL string) *mode
|
||||
bodyPage := a.NewEmailTemplate("signin_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.signin_change_email.body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.signin_change_email.body.info",
|
||||
bodyPage.Props["Info"] = T("api.templates.signin_change_email.body.info",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "Method": method})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendSignInChangeEmail", "api.user.send_sign_in_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -201,8 +204,9 @@ func (a *App) SendPasswordChangeEmail(email, method, locale, siteURL string) *mo
|
||||
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.password_change_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.password_change_body.info",
|
||||
bodyPage.Props["Info"] = T("api.templates.password_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "TeamURL": siteURL, "Method": method})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendPasswordChangeEmail", "api.user.send_password_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -211,16 +215,18 @@ func (a *App) SendPasswordChangeEmail(email, method, locale, siteURL string) *mo
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendUserAccessTokenAddedEmail(email, locale string) *model.AppError {
|
||||
func (a *App) SendUserAccessTokenAddedEmail(email, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.user_access_token_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.user_access_token_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.user_access_token_body.info",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "SiteURL": a.GetSiteURL()})
|
||||
bodyPage.Props["Info"] = T("api.templates.user_access_token_body.info",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "SiteURL": siteURL})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -241,7 +247,8 @@ func (a *App) SendPasswordResetEmail(email string, token *model.Token, locale, s
|
||||
bodyPage := a.NewEmailTemplate("reset_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.reset_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.reset_body.info", nil)
|
||||
bodyPage.Props["Info1"] = utils.TranslateAsHtml(T, "api.templates.reset_body.info1", nil)
|
||||
bodyPage.Props["Info2"] = T("api.templates.reset_body.info2")
|
||||
bodyPage.Props["ResetUrl"] = link
|
||||
bodyPage.Props["Button"] = T("api.templates.reset_body.button")
|
||||
|
||||
@@ -262,12 +269,13 @@ func (a *App) SendMfaChangeEmail(email string, activated bool, locale, siteURL s
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
|
||||
if activated {
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.mfa_activated_body.info", map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Info"] = T("api.templates.mfa_activated_body.info", map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Title"] = T("api.templates.mfa_activated_body.title")
|
||||
} else {
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.mfa_deactivated_body.info", map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Info"] = T("api.templates.mfa_deactivated_body.info", map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Title"] = T("api.templates.mfa_deactivated_body.title")
|
||||
}
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendMfaChangeEmail", "api.user.send_mfa_change_email.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -311,7 +319,8 @@ func (a *App) SendInviteEmails(team *model.Team, senderName string, senderUserId
|
||||
bodyPage.Props["Info"] = map[string]interface{}{}
|
||||
bodyPage.Props["Button"] = utils.T("api.templates.invite_body.button")
|
||||
bodyPage.Html["ExtraInfo"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body.extra_info",
|
||||
map[string]interface{}{"TeamDisplayName": team.DisplayName, "TeamURL": siteURL + "/" + team.Name})
|
||||
map[string]interface{}{"TeamDisplayName": team.DisplayName})
|
||||
bodyPage.Props["TeamURL"] = siteURL + "/" + team.Name
|
||||
|
||||
token := model.NewToken(
|
||||
TOKEN_TYPE_TEAM_INVITATION,
|
||||
@@ -359,8 +368,11 @@ func (a *App) NewEmailTemplate(name, locale string) *utils.HTMLTemplate {
|
||||
t.Props["Organization"] = ""
|
||||
}
|
||||
|
||||
t.Html["EmailInfo"] = utils.TranslateAsHtml(localT, "api.templates.email_info",
|
||||
map[string]interface{}{"SupportEmail": *a.Config().SupportSettings.SupportEmail, "SiteName": a.Config().TeamSettings.SiteName})
|
||||
t.Props["EmailInfo1"] = localT("api.templates.email_info1")
|
||||
t.Props["EmailInfo2"] = localT("api.templates.email_info2")
|
||||
t.Props["EmailInfo3"] = localT("api.templates.email_info3",
|
||||
map[string]interface{}{"SiteName": a.Config().TeamSettings.SiteName})
|
||||
t.Props["SupportEmail"] = *a.Config().SupportSettings.SupportEmail
|
||||
|
||||
return t
|
||||
}
|
||||
@@ -377,8 +389,9 @@ func (a *App) SendDeactivateAccountEmail(email string, locale, siteURL string) *
|
||||
bodyPage := a.NewEmailTemplate("deactivate_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.deactivate_body.title", map[string]interface{}{"ServerURL": rawUrl.Host})
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.deactivate_body.info",
|
||||
bodyPage.Props["Info"] = T("api.templates.deactivate_body.info",
|
||||
map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Warning"] = T("api.templates.deactivate_body.warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendDeactivateEmail", "api.user.send_deactivate_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -6,7 +6,6 @@ package app
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
@@ -550,12 +549,11 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
|
||||
t := getFormattedPostTime(recipient, post, useMilitaryTime, translateFunc)
|
||||
|
||||
var bodyText string
|
||||
var info template.HTML
|
||||
if channel.Type == model.CHANNEL_DIRECT {
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
bodyText = translateFunc("app.notification.body.intro.direct.full")
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.direct.full",
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.direct.full")
|
||||
bodyPage.Props["Info1"] = ""
|
||||
bodyPage.Props["Info2"] = translateFunc("app.notification.body.text.direct.full",
|
||||
map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
"Hour": t.Hour,
|
||||
@@ -565,10 +563,10 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
"Day": t.Day,
|
||||
})
|
||||
} else {
|
||||
bodyText = translateFunc("app.notification.body.intro.direct.generic", map[string]interface{}{
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.direct.generic", map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
})
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.direct.generic",
|
||||
bodyPage.Props["Info"] = translateFunc("app.notification.body.text.direct.generic",
|
||||
map[string]interface{}{
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
@@ -579,22 +577,25 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
}
|
||||
} else if channel.Type == model.CHANNEL_GROUP {
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
bodyText = translateFunc("app.notification.body.intro.group_message.full")
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.group_message.full",
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.group_message.full")
|
||||
bodyPage.Props["Info1"] = translateFunc("app.notification.body.text.group_message.full",
|
||||
map[string]interface{}{
|
||||
"ChannelName": channelName,
|
||||
"SenderName": senderName,
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
"TimeZone": t.TimeZone,
|
||||
"Month": t.Month,
|
||||
"Day": t.Day,
|
||||
})
|
||||
bodyPage.Props["Info2"] = translateFunc("app.notification.body.text.group_message.full2",
|
||||
map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
"TimeZone": t.TimeZone,
|
||||
"Month": t.Month,
|
||||
"Day": t.Day,
|
||||
})
|
||||
} else {
|
||||
bodyText = translateFunc("app.notification.body.intro.group_message.generic", map[string]interface{}{
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.group_message.generic", map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
})
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.group_message.generic",
|
||||
bodyPage.Props["Info"] = translateFunc("app.notification.body.text.group_message.generic",
|
||||
map[string]interface{}{
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
@@ -605,22 +606,25 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
}
|
||||
} else {
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
bodyText = translateFunc("app.notification.body.intro.notification.full")
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.notification.full",
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.notification.full")
|
||||
bodyPage.Props["Info1"] = translateFunc("app.notification.body.text.notification.full",
|
||||
map[string]interface{}{
|
||||
"ChannelName": channelName,
|
||||
"SenderName": senderName,
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
"TimeZone": t.TimeZone,
|
||||
"Month": t.Month,
|
||||
"Day": t.Day,
|
||||
})
|
||||
bodyPage.Props["Info2"] = translateFunc("app.notification.body.text.notification.full2",
|
||||
map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
"TimeZone": t.TimeZone,
|
||||
"Month": t.Month,
|
||||
"Day": t.Day,
|
||||
})
|
||||
} else {
|
||||
bodyText = translateFunc("app.notification.body.intro.notification.generic", map[string]interface{}{
|
||||
bodyPage.Props["BodyText"] = translateFunc("app.notification.body.intro.notification.generic", map[string]interface{}{
|
||||
"SenderName": senderName,
|
||||
})
|
||||
info = utils.TranslateAsHtml(translateFunc, "app.notification.body.text.notification.generic",
|
||||
bodyPage.Props["Info"] = translateFunc("app.notification.body.text.notification.generic",
|
||||
map[string]interface{}{
|
||||
"Hour": t.Hour,
|
||||
"Minute": t.Minute,
|
||||
@@ -631,8 +635,6 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
}
|
||||
}
|
||||
|
||||
bodyPage.Props["BodyText"] = bodyText
|
||||
bodyPage.Html["Info"] = info
|
||||
bodyPage.Props["Button"] = translateFunc("api.templates.post_body.button")
|
||||
|
||||
return bodyPage.Render()
|
||||
|
||||
@@ -261,7 +261,7 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
||||
mlog.Error(result.Err.Error())
|
||||
} else {
|
||||
user := result.Data.(*model.User)
|
||||
if err := a.SendUserAccessTokenAddedEmail(user.Email, user.Locale); err != nil {
|
||||
if err := a.SendUserAccessTokenAddedEmail(user.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
62
i18n/en.json
62
i18n/en.json
@@ -41,7 +41,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.admin.test_email.body",
|
||||
"translation": "<br/><br/><br/>It appears your Mattermost email is setup correctly!"
|
||||
"translation": "It appears your Mattermost email is setup correctly!"
|
||||
},
|
||||
{
|
||||
"id": "api.admin.test_email.missing_server",
|
||||
@@ -1736,7 +1736,11 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.deactivate_body.info",
|
||||
"translation": "You deactivated your account on {{ .SiteURL }}.<br>If this change wasn't initiated by you or you want to reactivate your account, contact your system administrator."
|
||||
"translation": "You deactivated your account on {{ .SiteURL }}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.deactivate_body.warning",
|
||||
"translation": "If this change was not initiated by you or you want to reactivate your account, contact your system administrator."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.deactivate_body.title",
|
||||
@@ -1748,7 +1752,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_change_body.info",
|
||||
"translation": "Your email address for {{.TeamDisplayName}} has been changed to {{.NewEmail}}.<br>If you did not make this change, please contact the system administrator."
|
||||
"translation": "Your email address for {{.TeamDisplayName}} has been changed to {{.NewEmail}}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_change_body.title",
|
||||
@@ -1779,24 +1783,36 @@
|
||||
"translation": "To change your notification preferences, log in to your team site and go to Account Settings > Notifications."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_info",
|
||||
"translation": "Any questions at all, mail us any time: <a href='mailto:{{.SupportEmail}}' style='text-decoration: none; color:#2389D7;'>{{.SupportEmail}}</a>.<br>Best wishes,<br>The {{.SiteName}} Team<br>"
|
||||
"id": "api.templates.email_info1",
|
||||
"translation": "Any questions at all, mail us any time: "
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_info2",
|
||||
"translation": "Best wishes,"
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_info3",
|
||||
"translation": "The {{.SiteName}} Team"
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_organization",
|
||||
"translation": "Sent by "
|
||||
},
|
||||
{
|
||||
"id": "api.templates.email_warning",
|
||||
"translation": "If you did not make this change, please contact the system administrator."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.invite_body.button",
|
||||
"translation": "Join Team"
|
||||
},
|
||||
{
|
||||
"id": "api.templates.invite_body.extra_info",
|
||||
"translation": "Mattermost lets you share messages and files from your PC or phone, with instant search and archiving. After you’ve joined <strong>{{.TeamDisplayName}}</strong>, you can sign-in to your new team and access these features anytime from the web address:<br/><br/><a href='{{.TeamURL}}'>{{.TeamURL}}</a>"
|
||||
"translation": "Mattermost lets you share messages and files from your PC or phone, with instant search and archiving. After you’ve joined [[{{.TeamDisplayName}}]], you can sign-in to your new team and access these features anytime from the web address:"
|
||||
},
|
||||
{
|
||||
"id": "api.templates.invite_body.info",
|
||||
"translation": "The team {{.SenderStatus}} <strong>{{.SenderName}}</strong>, has invited you to join <strong>{{.TeamDisplayName}}</strong>."
|
||||
"translation": "The team {{.SenderStatus}} [[{{.SenderName}}]], has invited you to join [[{{.TeamDisplayName}}]]."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.invite_body.title",
|
||||
@@ -1808,7 +1824,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.mfa_activated_body.info",
|
||||
"translation": "Multi-factor authentication has been added to your account on {{ .SiteURL }}.<br>If this change wasn't initiated by you, please contact your system administrator."
|
||||
"translation": "Multi-factor authentication has been added to your account on {{ .SiteURL }}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.mfa_activated_body.title",
|
||||
@@ -1820,7 +1836,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.mfa_deactivated_body.info",
|
||||
"translation": "Multi-factor authentication has been removed from your account on {{ .SiteURL }}.<br>If this change wasn't initiated by you, please contact your system administrator."
|
||||
"translation": "Multi-factor authentication has been removed from your account on {{ .SiteURL }}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.mfa_deactivated_body.title",
|
||||
@@ -1828,7 +1844,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.password_change_body.info",
|
||||
"translation": "Your password has been updated for {{.TeamDisplayName}} on {{ .TeamURL }} by {{.Method}}.<br>If this change wasn't initiated by you, please contact your system administrator."
|
||||
"translation": "Your password has been updated for {{.TeamDisplayName}} on {{ .TeamURL }} by {{.Method}}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.password_change_body.title",
|
||||
@@ -1847,8 +1863,12 @@
|
||||
"translation": "Reset Password"
|
||||
},
|
||||
{
|
||||
"id": "api.templates.reset_body.info",
|
||||
"translation": "To change your password, click \"Reset Password\" below.<br>If you did not mean to reset your password, please ignore this email and your password will remain the same. The password reset link expires in 24 hours."
|
||||
"id": "api.templates.reset_body.info1",
|
||||
"translation": "To change your password, click \"Reset Password\" below."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.reset_body.info2",
|
||||
"translation": "If you did not mean to reset your password, please ignore this email and your password will remain the same. The password reset link expires in 24 hours."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.reset_body.title",
|
||||
@@ -1860,7 +1880,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.signin_change_email.body.info",
|
||||
"translation": "You updated your sign-in method on {{ .SiteName }} to {{.Method}}.<br>If this change wasn't initiated by you, please contact your system administrator."
|
||||
"translation": "You updated your sign-in method on {{ .SiteName }} to {{.Method}}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.signin_change_email.body.method_email",
|
||||
@@ -1876,7 +1896,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.user_access_token_body.info",
|
||||
"translation": "A personal access token was added to your account on {{ .SiteURL }}. They can be used to access {{.SiteName}} with your account.<br>If this change wasn't initiated by you, please contact your system administrator."
|
||||
"translation": "A personal access token was added to your account on {{ .SiteURL }}. They can be used to access {{.SiteName}} with your account."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.user_access_token_body.title",
|
||||
@@ -1888,7 +1908,7 @@
|
||||
},
|
||||
{
|
||||
"id": "api.templates.username_change_body.info",
|
||||
"translation": "Your username for {{.TeamDisplayName}} has been changed to {{.NewUsername}}.<br>If you did not make this change, please contact the system administrator."
|
||||
"translation": "Your username for {{.TeamDisplayName}} has been changed to {{.NewUsername}}."
|
||||
},
|
||||
{
|
||||
"id": "api.templates.username_change_body.title",
|
||||
@@ -2968,7 +2988,11 @@
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.group_message.full",
|
||||
"translation": "Channel: {{.ChannelName}}<br>@{{.SenderName}} - {{.Hour}}:{{.Minute}} {{.TimeZone}}, {{.Month}} {{.Day}}"
|
||||
"translation": "Channel: {{.ChannelName}}"
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.group_message.full2",
|
||||
"translation": "@{{.SenderName}} - {{.Hour}}:{{.Minute}} {{.TimeZone}}, {{.Month}} {{.Day}}"
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.group_message.generic",
|
||||
@@ -2976,7 +3000,11 @@
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.notification.full",
|
||||
"translation": "Channel: {{.ChannelName}}<br>@{{.SenderName}} - {{.Hour}}:{{.Minute}} {{.TimeZone}}, {{.Month}} {{.Day}}"
|
||||
"translation": "Channel: {{.ChannelName}}"
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.notification.full2",
|
||||
"translation": "@{{.SenderName}} - {{.Hour}}:{{.Minute}} {{.TimeZone}}, {{.Month}} {{.Day}}"
|
||||
},
|
||||
{
|
||||
"id": "app.notification.body.text.notification.generic",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info}}<br>{{.Props.Warning}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info}}<br>{{.Props.Warning}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{define "email_info"}}
|
||||
|
||||
<td style="color: #999; padding-top: 20px; line-height: 25px; font-size: 13px;">
|
||||
{{.Html.EmailInfo}}
|
||||
{{.Props.EmailInfo1}}<a href='mailto:{{.Props.SupportEmail}}' style='text-decoration: none; color:#2389D7;'>{{.Props.SupportEmail}}</a><br>{{.Props.EmailInfo2}}<br>{{.Props.EmailInfo3}}<br>
|
||||
</td>
|
||||
|
||||
{{end}}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<a href="{{.Props.Link}}" style="background: #2389D7; border-radius: 3px; color: #fff; border: none; outline: none; min-width: 200px; padding: 15px 25px; font-size: 14px; font-family: inherit; cursor: pointer; -webkit-appearance: none;text-decoration: none;">{{.Props.Button}}</a>
|
||||
</p>
|
||||
<br/>
|
||||
<p>{{.Html.ExtraInfo}}</p>
|
||||
<p>{{.Html.ExtraInfo}}<br/><br/><a href='{{.Props.TeamURL}}'>{{.Props.TeamURL}}</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info}}<br>{{.Props.Warning}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info}}<br>{{.Props.Warning}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.BodyText}}</h2>
|
||||
<p>{{.Html.Info}}<br><pre style="text-align:left;font-family: 'Lato', sans-serif; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">{{.Props.PostMessage}}</pre></p>
|
||||
<p>{{.Props.Info1}}<br>{{.Props.Info2}}<br><pre style="text-align:left;font-family: 'Lato', sans-serif; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">{{.Props.PostMessage}}</pre></p>
|
||||
<p style="margin: 20px 0 15px">
|
||||
<a href="{{.Props.TeamLink}}" style="background: #2389D7; display: inline-block; border-radius: 3px; color: #fff; border: none; outline: none; min-width: 170px; padding: 15px 25px; font-size: 14px; font-family: inherit; cursor: pointer; -webkit-appearance: none;text-decoration: none;">{{.Props.Button}}</a>
|
||||
</p>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info1}}<br>{{.Props.Info2}}</p>
|
||||
<p style="margin: 20px 0 15px">
|
||||
<a href="{{.Props.ResetUrl}}" style="background: #2389D7; border-radius: 3px; color: #fff; border: none; outline: none; min-width: 200px; padding: 15px 25px; font-size: 14px; font-family: inherit; cursor: pointer; -webkit-appearance: none;text-decoration: none;">{{.Props.Button}}</a>
|
||||
</p>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr>
|
||||
<td style="border-bottom: 1px solid #ddd; padding: 0 0 20px;">
|
||||
<h2 style="font-weight: normal; margin-top: 10px;">{{.Props.Title}}</h2>
|
||||
<p>{{.Html.Info}}</p>
|
||||
<p>{{.Props.Info}}<br>{{.Props.Warning}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
@@ -119,7 +120,10 @@ func (t *HTMLTemplate) RenderToWriter(w io.Writer) error {
|
||||
}
|
||||
|
||||
func TranslateAsHtml(t i18n.TranslateFunc, translationID string, args map[string]interface{}) template.HTML {
|
||||
return template.HTML(t(translationID, escapeForHtml(args)))
|
||||
message := t(translationID, escapeForHtml(args))
|
||||
message = strings.Replace(message, "[[", "<strong>", -1)
|
||||
message = strings.Replace(message, "]]", "</strong>", -1)
|
||||
return template.HTML(message)
|
||||
}
|
||||
|
||||
func escapeForHtml(arg interface{}) interface{} {
|
||||
|
||||
@@ -28,7 +28,7 @@ func init() {
|
||||
htmlTestTranslationBundle = bundle.New()
|
||||
fooBold, _ := translation.NewTranslation(map[string]interface{}{
|
||||
"id": "foo.bold",
|
||||
"translation": "<b>{{ .Foo }}</b>",
|
||||
"translation": "<p>[[{{ .Foo }}]]</p>",
|
||||
})
|
||||
htmlTestTranslationBundle.AddTranslation(&language.Language{Tag: "en"}, fooBold)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func TestHTMLTemplate_RenderError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTranslateAsHtml(t *testing.T) {
|
||||
assert.EqualValues(t, "<b><i>foo</i></b>", TranslateAsHtml(i18n.TranslateFunc(htmlTestTranslationBundle.MustTfunc("en")), "foo.bold", map[string]interface{}{
|
||||
assert.EqualValues(t, "<p><strong><i>foo</i></strong></p>", TranslateAsHtml(i18n.TranslateFunc(htmlTestTranslationBundle.MustTfunc("en")), "foo.bold", map[string]interface{}{
|
||||
"Foo": "<i>foo</i>",
|
||||
}))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user