2020-05-20 12:28:08 +00:00
|
|
|
package templates
|
|
|
|
|
2020-06-09 13:11:42 +00:00
|
|
|
import (
|
2020-10-20 17:10:23 +00:00
|
|
|
"html"
|
|
|
|
|
2020-06-09 13:11:42 +00:00
|
|
|
"github.com/caos/zitadel/internal/i18n"
|
|
|
|
)
|
|
|
|
|
2020-05-20 12:28:08 +00:00
|
|
|
type TemplateData struct {
|
2020-10-20 17:10:23 +00:00
|
|
|
Title string
|
|
|
|
PreHeader string
|
|
|
|
Subject string
|
|
|
|
Greeting string
|
|
|
|
Text string
|
|
|
|
Href string
|
|
|
|
ButtonText string
|
|
|
|
PrimaryColor string
|
|
|
|
SecondaryColor string
|
2020-05-20 12:28:08 +00:00
|
|
|
}
|
2020-06-09 13:11:42 +00:00
|
|
|
|
|
|
|
func (data *TemplateData) Translate(i18n *i18n.Translator, args map[string]interface{}, langs ...string) {
|
|
|
|
data.Title = i18n.Localize(data.Title, nil, langs...)
|
|
|
|
data.PreHeader = i18n.Localize(data.PreHeader, nil, langs...)
|
|
|
|
data.Subject = i18n.Localize(data.Subject, nil, langs...)
|
|
|
|
data.Greeting = i18n.Localize(data.Greeting, args, langs...)
|
2020-10-20 17:10:23 +00:00
|
|
|
data.Text = html.UnescapeString(i18n.Localize(data.Text, args, langs...))
|
2020-06-09 13:11:42 +00:00
|
|
|
data.Href = i18n.Localize(data.Href, nil, langs...)
|
|
|
|
data.ButtonText = i18n.Localize(data.ButtonText, nil, langs...)
|
|
|
|
}
|