github.com/gogf/gf@v1.16.9/.example/i18n/gi18n/http_view_i18n.go (about) 1 package main 2 3 import ( 4 "github.com/gogf/gf/frame/g" 5 "github.com/gogf/gf/i18n/gi18n" 6 "github.com/gogf/gf/net/ghttp" 7 ) 8 9 func main() { 10 s := g.Server() 11 s.Group("/", func(group *ghttp.RouterGroup) { 12 group.Middleware(func(r *ghttp.Request) { 13 r.SetCtx(gi18n.WithLanguage(r.Context(), r.GetString("lang", "zh-CN"))) 14 r.Middleware.Next() 15 }) 16 group.ALL("/", func(r *ghttp.Request) { 17 r.Response.WriteTplContent(`{#hello}{#world}!`) 18 }) 19 }) 20 s.SetPort(8199) 21 s.Run() 22 }