From 733a802357929d982f8a7b89f81dba90d2fbf3dd Mon Sep 17 00:00:00 2001 From: Azareal Date: Tue, 9 Apr 2019 17:21:00 +1000 Subject: [PATCH] Use the langpack's isocode in header.html instead of en. Added the GetLangPack function. --- common/pages.go | 1 + common/phrases/phrases.go | 4 ++++ common/routes_common.go | 4 ++++ templates/header.html | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/pages.go b/common/pages.go index 41227120..2edbf816 100644 --- a/common/pages.go +++ b/common/pages.go @@ -42,6 +42,7 @@ type Header struct { //OGImage string OGDesc string GoogSiteVerify string + IsoCode string LooseCSP bool StartedAt time.Time Elapsed1 string diff --git a/common/phrases/phrases.go b/common/phrases/phrases.go index 9b8a78c1..1a4dfd23 100644 --- a/common/phrases/phrases.go +++ b/common/phrases/phrases.go @@ -151,6 +151,10 @@ func SaveLangPack(langPack *LanguagePack) error { return nil } +func GetLangPack() *LanguagePack { + return currentLangPack.Load().(*LanguagePack) +} + func GetLevelPhrase(level int) string { levelPhrases := currentLangPack.Load().(*LanguagePack).Levels if len(levelPhrases.Levels) > 0 && level < len(levelPhrases.Levels) { diff --git a/common/routes_common.go b/common/routes_common.go index 18449673..082cce70 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -7,6 +7,8 @@ import ( "strconv" "strings" "time" + + "github.com/Azareal/Gosora/common/phrases" ) // nolint @@ -114,6 +116,7 @@ func panelUserCheck(w http.ResponseWriter, r *http.Request, user *User) (header Hooks: GetHookTable(), Zone: "panel", Writer: w, + IsoCode: phrases.GetLangPack().IsoCode, } // TODO: We should probably initialise header.ExtData // ? - Should we only show this in debug mode? It might be useful for detecting issues in production, if we show it there as-well @@ -207,6 +210,7 @@ func userCheck(w http.ResponseWriter, r *http.Request, user *User) (header *Head Hooks: GetHookTable(), Zone: "frontend", Writer: w, + IsoCode: phrases.GetLangPack().IsoCode, } header.GoogSiteVerify = header.Settings["google_site_verify"].(string) diff --git a/templates/header.html b/templates/header.html index 55b5b63d..2b75bab7 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,5 +1,5 @@ - + {{.Title}} | {{.Header.Site.Name}} {{range .Header.Stylesheets}}