This commit is contained in:
xing 2023-01-19 14:12:59 +08:00
parent b768ec10bd
commit 6bde2bcfd3
6 changed files with 13 additions and 3 deletions

View File

@ -3,8 +3,8 @@ package actions
import ( import (
"fmt" "fmt"
"github.com/fthvgb1/wp-go/helper" "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/internal/wpconfig"
"github.com/fthvgb1/wp-go/phpass"
"github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"

View File

@ -16,6 +16,7 @@ var funcs = template.FuncMap{
"getOption": func(k string) string { "getOption": func(k string) string {
return wpconfig.Options.Value(k) return wpconfig.Options.Value(k)
}, },
"getLang": wpconfig.GetLang,
} }
func FuncMap() template.FuncMap { func FuncMap() template.FuncMap {

View File

@ -1,6 +1,6 @@
{{ define "layout/base"}} {{ define "layout/base"}}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{"WPLANG"| getOption}}" class="no-js"> <html lang="{{getLang}}" class="no-js">
<head> <head>
{{template "layout/head" .}} {{template "layout/head" .}}
{{block "head" .}} {{block "head" .}}

View File

@ -1,6 +1,6 @@
{{ define "layout/base"}} {{ define "layout/base"}}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{"WPLANG"| getOption}}" class="no-js no-svg"> <html lang="{{getLang}}" class="no-js no-svg">
<head> <head>
{{template "layout/head" .}} {{template "layout/head" .}}
{{block "head" .}} {{block "head" .}}

View File

@ -5,6 +5,7 @@ import (
"github.com/fthvgb1/wp-go/internal/pkg/models" "github.com/fthvgb1/wp-go/internal/pkg/models"
"github.com/fthvgb1/wp-go/model" "github.com/fthvgb1/wp-go/model"
"github.com/fthvgb1/wp-go/safety" "github.com/fthvgb1/wp-go/safety"
"strings"
) )
var Options safety.Map[string, string] var Options safety.Map[string, string]
@ -26,3 +27,11 @@ func InitOptions() error {
} }
return nil return nil
} }
func GetLang() string {
s, ok := Options.Load("WPLANG")
if !ok {
s = "zh-CN"
}
return strings.Replace(s, "_", "-", 1)
}