更新一些设计

This commit is contained in:
yun
2025-10-26 15:41:30 +08:00
parent 046091cb35
commit 38a46b85e1
3 changed files with 94 additions and 26 deletions
+22 -4
View File
@@ -9,9 +9,27 @@ func SetCtxLang(ctx context.Context, lang string) context.Context {
}
func GetCtxLang(ctx context.Context) string {
lang, ok := ctx.Value(ctxLangKey).(string)
if !ok {
return ""
// 指定的
lang := ctx.Value(ctxLangKey)
l := ""
if lang != nil {
l = lang.(string)
}
return lang
// HTTP头部的
if l == "" {
lang = ctx.Value("Accept-Language")
if lang != nil {
l = lang.(string)
}
}
// 默认的
if l == "" {
l = GetDefaultLang()
}
return l
}