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) +}