From 6bde2bcfd38f968397c1ac9e23cb6592fd35b0fa Mon Sep 17 00:00:00 2001 From: xing Date: Thu, 19 Jan 2023 14:12:59 +0800 Subject: [PATCH] fix --- internal/actions/login.go | 2 +- {phpass => internal/phpass}/phpass.go | 0 internal/theme/templateFuncs.go | 1 + internal/theme/twentyfifteen/layout/base.gohtml | 2 +- internal/theme/twentyseventeen/layout/base.gohtml | 2 +- internal/wpconfig/options.go | 9 +++++++++ 6 files changed, 13 insertions(+), 3 deletions(-) rename {phpass => internal/phpass}/phpass.go (100%) diff --git a/internal/actions/login.go b/internal/actions/login.go index 2bd1f32..85a7aac 100644 --- a/internal/actions/login.go +++ b/internal/actions/login.go @@ -3,8 +3,8 @@ package actions import ( "fmt" "github.com/fthvgb1/wp-go/helper" + "github.com/fthvgb1/wp-go/internal/phpass" "github.com/fthvgb1/wp-go/internal/wpconfig" - "github.com/fthvgb1/wp-go/phpass" "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "net/http" diff --git a/phpass/phpass.go b/internal/phpass/phpass.go similarity index 100% rename from phpass/phpass.go rename to internal/phpass/phpass.go diff --git a/internal/theme/templateFuncs.go b/internal/theme/templateFuncs.go index 6c8a814..d5f2d2b 100644 --- a/internal/theme/templateFuncs.go +++ b/internal/theme/templateFuncs.go @@ -16,6 +16,7 @@ var funcs = template.FuncMap{ "getOption": func(k string) string { return wpconfig.Options.Value(k) }, + "getLang": wpconfig.GetLang, } func FuncMap() template.FuncMap { diff --git a/internal/theme/twentyfifteen/layout/base.gohtml b/internal/theme/twentyfifteen/layout/base.gohtml index 87569c8..91ccebe 100644 --- a/internal/theme/twentyfifteen/layout/base.gohtml +++ b/internal/theme/twentyfifteen/layout/base.gohtml @@ -1,6 +1,6 @@ {{ define "layout/base"}} - + {{template "layout/head" .}} {{block "head" .}} diff --git a/internal/theme/twentyseventeen/layout/base.gohtml b/internal/theme/twentyseventeen/layout/base.gohtml index e94255f..3c35463 100644 --- a/internal/theme/twentyseventeen/layout/base.gohtml +++ b/internal/theme/twentyseventeen/layout/base.gohtml @@ -1,6 +1,6 @@ {{ define "layout/base"}} - + {{template "layout/head" .}} {{block "head" .}} diff --git a/internal/wpconfig/options.go b/internal/wpconfig/options.go index 7b51d98..3424bbd 100644 --- a/internal/wpconfig/options.go +++ b/internal/wpconfig/options.go @@ -5,6 +5,7 @@ import ( "github.com/fthvgb1/wp-go/internal/pkg/models" "github.com/fthvgb1/wp-go/model" "github.com/fthvgb1/wp-go/safety" + "strings" ) var Options safety.Map[string, string] @@ -26,3 +27,11 @@ func InitOptions() error { } return nil } + +func GetLang() string { + s, ok := Options.Load("WPLANG") + if !ok { + s = "zh-CN" + } + return strings.Replace(s, "_", "-", 1) +}