fix HTML in i18n strings
previously it just worked on errors
This commit is contained in:
parent
4558b208ee
commit
336596552e
|
@ -83,10 +83,10 @@ type errorTemplateData struct {
|
|||
BackURL string
|
||||
}
|
||||
|
||||
func localizeError(ih *i18n.Localizer, err error) (int, string) {
|
||||
func localizeError(ih *i18n.Localizer, err error) (int, template.HTML) {
|
||||
|
||||
// default, unlocalized message
|
||||
msg := err.Error()
|
||||
msg := template.HTML(err.Error())
|
||||
|
||||
// localize some specific error messages
|
||||
var (
|
||||
|
|
|
@ -3,6 +3,7 @@ package errors
|
|||
import (
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
|
@ -38,7 +39,7 @@ const (
|
|||
|
||||
type FlashMessage struct {
|
||||
Kind FlashKind
|
||||
Message string
|
||||
Message template.HTML
|
||||
}
|
||||
|
||||
// TODO: rethink error return - maybe panic() / maybe render package?
|
||||
|
|
|
@ -58,7 +58,7 @@ AuthFallbackInstruct = "Diese Methode ist ein akzeptabler Fallback, wenn Sie ein
|
|||
AuthFallbackNewPassword="Neues Passwort"
|
||||
AuthFallbackRepeatPassword="Passwort wiederholen"
|
||||
AuthFallbackPasswordChangeFormTitle = "Passwort ändern"
|
||||
AuthFallbackPasswordChangeWelcome = "Hier können Sie ihr Passwort neu setzen. Bitte achten sie darauf, dass es länger als 10 Zeichen ist. Durch die doppelte eingabe wird sichergestellt, dass Sie sich nicht vertippt haben. Auserdem verwenden wir die Datenbank von haveibeenpwned.com um sicher zu stellen, dass Sie kein unsicherers Passwort verwenden, ohne es zu wissen."
|
||||
AuthFallbackPasswordChangeWelcome = "Hier können Sie ihr Passwort neu setzen. Bitte achten sie darauf, dass es länger als 10 Zeichen ist. Durch die doppelte eingabe wird sichergestellt, dass Sie sich nicht vertippt haben. Auserdem verwenden wir die Datenbank von <a href='https://haveibeenpwned.com'>haveibeenpwned.com</a> um sicher zu stellen, dass Sie kein unsicherers Passwort verwenden, ohne es zu wissen."
|
||||
AuthFallbackPasswordUpdated = "Das Passwort wurde aktualisiert. Sie können sich nun damit Einloggen."
|
||||
AdminMemberPasswordResetLinkCreatedTitle = "Passwort reset link erstellt"
|
||||
AdminMemberPasswordResetLinkCreatedInstruct = "Der reset Link wurde erstellt. Bitte senden Sie ihn, uber einen geeigneten Seitenkanal wie z.B. E-Mail, an das Mitglied. Wenn die Person den Link offnet, ist Sie in der Lage sich ein neues Passwort zu geben."
|
||||
|
|
|
@ -65,7 +65,7 @@ AuthFallbackInstruct = "This method is an acceptable fallback, if you have a use
|
|||
AuthFallbackNewPassword="New Password"
|
||||
AuthFallbackRepeatPassword="Repeat Password"
|
||||
AuthFallbackPasswordChangeFormTitle = "Change Password"
|
||||
AuthFallbackPasswordChangeWelcome = "Here you can change your fallback password. Please make sure it's longer then 10 characters. Via the repition we make sure that you don't accidentally mistype it. Additionally we use the lookup from haveibeenpwned.com to make sure you don't accidentally use a weak password."
|
||||
AuthFallbackPasswordChangeWelcome = "Here you can change your fallback password. Please make sure it's longer then 10 characters. Via the repition we make sure that you don't accidentally mistype it. Additionally we use the lookup from <a href='https://haveibeenpwned.com'>haveibeenpwned.com</a> to make sure you don't accidentally use a weak password."
|
||||
AuthFallbackPasswordUpdated = "The password was updated. You can now use it to sign in."
|
||||
AdminMemberPasswordResetLinkCreatedTitle = "Password reset token created"
|
||||
AdminMemberPasswordResetLinkCreatedInstruct = "The reset token was created. Please send it to the member via some means (like E-Mail or another suitable side-channel). When they open it, they will be able to choose a new password for themselves."
|
||||
|
|
|
@ -5,6 +5,7 @@ package i18n
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
|
@ -248,30 +249,30 @@ func (h Helper) GetRenderFuncs() []render.Option {
|
|||
return opts
|
||||
}
|
||||
|
||||
func (l Localizer) LocalizeSimple(messageID string) string {
|
||||
func (l Localizer) LocalizeSimple(messageID string) template.HTML {
|
||||
msg, err := l.loc.Localize(&i18n.LocalizeConfig{
|
||||
MessageID: messageID,
|
||||
})
|
||||
if err == nil {
|
||||
return msg
|
||||
return template.HTML(msg)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("i18n/error: failed to localize label %s: %s", messageID, err))
|
||||
}
|
||||
|
||||
func (l Localizer) LocalizeWithData(messageID string, tplData map[string]string) string {
|
||||
func (l Localizer) LocalizeWithData(messageID string, tplData map[string]string) template.HTML {
|
||||
msg, err := l.loc.Localize(&i18n.LocalizeConfig{
|
||||
MessageID: messageID,
|
||||
TemplateData: tplData,
|
||||
})
|
||||
if err == nil {
|
||||
return msg
|
||||
return template.HTML(msg)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("i18n/error: failed to localize label %s: %s", messageID, err))
|
||||
}
|
||||
|
||||
func (l Localizer) LocalizePlurals(messageID string, pluralCount int) string {
|
||||
func (l Localizer) LocalizePlurals(messageID string, pluralCount int) template.HTML {
|
||||
msg, err := l.loc.Localize(&i18n.LocalizeConfig{
|
||||
MessageID: messageID,
|
||||
PluralCount: pluralCount,
|
||||
|
@ -280,20 +281,20 @@ func (l Localizer) LocalizePlurals(messageID string, pluralCount int) string {
|
|||
},
|
||||
})
|
||||
if err == nil {
|
||||
return msg
|
||||
return template.HTML(msg)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("i18n/error: failed to localize label %s: %s", messageID, err))
|
||||
}
|
||||
|
||||
func (l Localizer) LocalizePluralsWithData(messageID string, pluralCount int, tplData map[string]string) string {
|
||||
func (l Localizer) LocalizePluralsWithData(messageID string, pluralCount int, tplData map[string]string) template.HTML {
|
||||
msg, err := l.loc.Localize(&i18n.LocalizeConfig{
|
||||
MessageID: messageID,
|
||||
PluralCount: pluralCount,
|
||||
TemplateData: tplData,
|
||||
})
|
||||
if err == nil {
|
||||
return msg
|
||||
return template.HTML(msg)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("i18n/error: failed to localize label %s: %s", messageID, err))
|
||||
|
|
Loading…
Reference in New Issue