diff --git a/common/phrases/phrases.go b/common/phrases/phrases.go index f8e502de..39a808ba 100644 --- a/common/phrases/phrases.go +++ b/common/phrases/phrases.go @@ -48,7 +48,8 @@ type LanguagePack struct { UserAgents map[string]string OperatingSystems map[string]string HumanLanguages map[string]string - Errors map[string]string + Errors map[string]string // Temp stand-in + ErrorsBytes map[string][]byte NoticePhrases map[string]string PageTitles map[string]string TmplPhrases map[string]string @@ -85,6 +86,11 @@ func InitPhrases(lang string) error { return err } + langPack.ErrorsBytes = make(map[string][]byte) + for name, phrase := range langPack.Errors { + langPack.ErrorsBytes[name] = []byte(phrase) + } + // [prefix][name]phrase langPack.TmplPhrasesPrefixes = make(map[string]map[string]string) for name, phrase := range langPack.TmplPhrases { @@ -222,6 +228,13 @@ func GetErrorPhrase(name string) string { } return res } +func GetErrorPhraseBytes(name string) []byte { + res, ok := currentLangPack.Load().(*LanguagePack).ErrorsBytes[name] + if !ok { + return getPlaceholderBytes("error", name) + } + return res +} func GetNoticePhrase(name string) string { res, ok := currentLangPack.Load().(*LanguagePack).NoticePhrases[name] @@ -275,6 +288,9 @@ func GetTmplPhrasesByPrefix(prefix string) (phrases map[string]string, ok bool) func getPlaceholder(prefix string, suffix string) string { return "{lang." + prefix + "[" + suffix + "]}" } +func getPlaceholderBytes(prefix string, suffix string) []byte { + return []byte("{lang." + prefix + "[" + suffix + "]}") +} // Please don't mutate *LanguagePack func GetCurrentLangPack() *LanguagePack { diff --git a/templates/topic_alt.html b/templates/topic_alt.html index 87d2722f..eb985fcf 100644 --- a/templates/topic_alt.html +++ b/templates/topic_alt.html @@ -75,7 +75,7 @@