mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
2598745e50
Co-authored-by: houseme <housemecn@gmail.com>
29 lines
574 B
Go
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()
|
|
}
|