Use the langpack's isocode in header.html instead of en.

Added the GetLangPack function.
This commit is contained in:
Azareal 2019-04-09 17:21:00 +10:00
parent e9f1a3c677
commit 733a802357
4 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,7 @@ type Header struct {
//OGImage string
OGDesc string
GoogSiteVerify string
IsoCode string
LooseCSP bool
StartedAt time.Time
Elapsed1 string

View File

@ -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) {

View File

@ -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)

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html{{if .Header.IsoCode}} lang="{{.Header.IsoCode}}"{{end}}>
<head>
<title>{{.Title}} | {{.Header.Site.Name}}</title>
{{range .Header.Stylesheets}}