增加多语言支持

This commit is contained in:
2025-12-07 10:32:36 +08:00
parent 684923f9cb
commit f8f4df4073
9 changed files with 1287 additions and 5 deletions

View File

@@ -104,3 +104,11 @@ func ParseJSON(r *http.Request, v interface{}) error {
func GetTimezone(r *http.Request) string {
return middleware.GetTimezoneFromContext(r.Context())
}
// GetLanguage 从请求的context中获取语言公共方法
// r: HTTP请求
// 如果使用了middleware.Language中间件可以从context中获取语言信息
// 如果未设置,返回默认语言 zh-CN
func GetLanguage(r *http.Request) string {
return middleware.GetLanguageFromContext(r.Context())
}