mirror of https://gitee.com/answerdev/answer.git
add language
This commit is contained in:
parent
9ca6445d3a
commit
332ec7c966
|
@ -4,12 +4,15 @@ import (
|
|||
"html/template"
|
||||
"io/fs"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
brotli "github.com/anargu/gin-brotli"
|
||||
"github.com/answerdev/answer/internal/base/middleware"
|
||||
"github.com/answerdev/answer/internal/base/translator"
|
||||
"github.com/answerdev/answer/internal/router"
|
||||
"github.com/answerdev/answer/ui"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/segmentfault/pacman/i18n"
|
||||
)
|
||||
|
||||
// NewHTTPServer new http server.
|
||||
|
@ -58,6 +61,12 @@ func NewHTTPServer(debug bool,
|
|||
"templateHTML": func(data string) template.HTML {
|
||||
return template.HTML(data)
|
||||
},
|
||||
"translator": func(la i18n.Language, data string) string {
|
||||
return translator.GlobalTrans.Tr(la, data)
|
||||
},
|
||||
"translatorTimeFormat": func(la i18n.Language, timestamp int64) string {
|
||||
return time.Unix(timestamp, 0).Format("2006-01-02 15:04:05")
|
||||
},
|
||||
})
|
||||
|
||||
dev := os.Getenv("DEVCODE")
|
||||
|
|
|
@ -274,6 +274,7 @@ func (tc *TemplateController) UserInfo(ctx *gin.Context) {
|
|||
"userinfo": userinfo,
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"language": handler.GetLang(ctx),
|
||||
"bio": template.HTML(userinfo.Info.BioHTML),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{template "header" . }}
|
||||
|
||||
|
||||
{{translatorTimeFormat $.language 1669920355}}
|
||||
{{translator $.language "error.object.old_password_verification_failed"}}
|
||||
<div class="pt-4 mt-2 mb-5 container">
|
||||
<div class="justify-content-center row">
|
||||
<div class="col-xxl-7 col-lg-8 col-sm-12">
|
||||
|
|
Loading…
Reference in New Issue