fix i18n header bug (#1095)

Co-authored-by: ziv <xiaozheng@tuya.com>
This commit is contained in:
xiaoziv 2022-08-08 20:28:36 +08:00 committed by GitHub
parent bd0480216c
commit fd3e51cbb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -37,12 +37,12 @@ func languageDetector() gin.HandlerFunc {
if headerKey != "" {
lang := c.GetHeader(headerKey)
if lang != "" {
if strings.HasSuffix(lang, "*") || strings.HasPrefix(lang, "zh") {
c.Header("X-Language", "zh")
if strings.HasPrefix(lang, "*") || strings.HasPrefix(lang, "zh") {
c.Request.Header.Set("X-Language", "zh")
} else if strings.HasPrefix(lang, "en") {
c.Header("X-Language", "en")
c.Request.Header.Set("X-Language", "en")
} else {
c.Header("X-Language", lang)
c.Request.Header.Set("X-Language", lang)
}
}
}