This commit is contained in:
2025-06-20 17:13:51 +08:00
parent 1b55403cd6
commit fd0345a034
472 changed files with 52560 additions and 77 deletions

View File

@@ -0,0 +1,23 @@
package middleware
import (
"strings"
"github.com/cool-team-official/cool-admin-go/cool"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
func AutoI18n(r *ghttp.Request) {
Language := r.GetHeader("Accept-Language")
Language = strings.Split(Language, ",")[0]
cool.I18n.SetLanguage(Language)
r.Response.Header().Set("Content-Language", Language)
r.Middleware.Next()
}
func I18nInfo(r *ghttp.Request) {
r.Response.WriteJson(g.Map{
r.Response.Header().Get("Content-Language"): cool.I18n.Translate(r.Context(), "BaseResMessage"),
})
}