mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Fix router error message's i18n
This commit is contained in:
@ -19,6 +19,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/context"
|
||||
"github.com/casdoor/casdoor/conf"
|
||||
"github.com/casdoor/casdoor/i18n"
|
||||
"github.com/casdoor/casdoor/object"
|
||||
"github.com/casdoor/casdoor/util"
|
||||
)
|
||||
@ -46,8 +48,17 @@ func responseError(ctx *context.Context, error string, data ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func getAcceptLanguage(ctx *context.Context) string {
|
||||
language := ctx.Request.Header.Get("Accept-Language")
|
||||
return conf.GetLanguage(language)
|
||||
}
|
||||
|
||||
func T(ctx *context.Context, error string) string {
|
||||
return i18n.Translate(getAcceptLanguage(ctx), error)
|
||||
}
|
||||
|
||||
func denyRequest(ctx *context.Context) {
|
||||
responseError(ctx, "Unauthorized operation")
|
||||
responseError(ctx, T(ctx, "auth:Unauthorized operation"))
|
||||
}
|
||||
|
||||
func getUsernameByClientIdSecret(ctx *context.Context) string {
|
||||
|
Reference in New Issue
Block a user