gf/example/pack/main.go
John Guo 2598745e50
fix issue #1971 (#2203)
Co-authored-by: houseme <housemecn@gmail.com>
2022-10-14 10:10:27 +08:00

29 lines
574 B
Go

package main
import (
_ "github.com/gogf/gf/example/pack/packed"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/i18n/gi18n"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gres"
)
func main() {
gres.Dump()
s := g.Server()
s.SetPort(8199)
s.SetServerRoot("resource/public")
s.BindHandler("/i18n", func(r *ghttp.Request) {
var (
lang = r.Get("lang", "zh-CN").String()
ctx = gi18n.WithLanguage(r.Context(), lang)
content string
)
content = g.I18n().T(ctx, `{#hello} {#world}!`)
r.Response.Write(content)
})
s.Run()
}