Fix router error message's i18n

This commit is contained in:
Yang Luo
2023-02-18 16:11:23 +08:00
parent 19fb7273bb
commit 842d4865b2
4 changed files with 29 additions and 8 deletions

View File

@ -17,7 +17,6 @@ package controllers
import (
"fmt"
"strconv"
"strings"
"github.com/casdoor/casdoor/conf"
"github.com/casdoor/casdoor/i18n"
@ -56,11 +55,8 @@ func (c *ApiController) T(error string) string {
// GetAcceptLanguage ...
func (c *ApiController) GetAcceptLanguage() string {
lang := c.Ctx.Request.Header.Get("Accept-Language")
if lang == "" || !strings.Contains(conf.GetConfigString("languages"), lang[0:2]) {
lang = "en"
}
return lang[0:2]
language := c.Ctx.Request.Header.Get("Accept-Language")
return conf.GetLanguage(language)
}
// SetTokenErrorHttpStatus ...