mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-09 02:03:42 +08:00
refactor: update UI text and error messages to English for better accessibility
This commit is contained in:
@@ -27,7 +27,7 @@ func authHelper(c *gin.Context, minRole int) {
|
||||
if accessToken == "" {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"success": false,
|
||||
"message": "无权进行此操作,未登录且未提供 access token",
|
||||
"message": "No permission to perform this operation, not logged in and no access token provided",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
@@ -43,7 +43,7 @@ func authHelper(c *gin.Context, minRole int) {
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "无权进行此操作,access token 无效",
|
||||
"message": "No permission to perform this operation, access token is invalid",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
@@ -52,7 +52,7 @@ func authHelper(c *gin.Context, minRole int) {
|
||||
if status.(int) == model.UserStatusDisabled || blacklist.IsUserBanned(id.(int)) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "用户已被封禁",
|
||||
"message": "User has been banned",
|
||||
})
|
||||
session := sessions.Default(c)
|
||||
session.Clear()
|
||||
@@ -63,7 +63,7 @@ func authHelper(c *gin.Context, minRole int) {
|
||||
if role.(int) < minRole {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "无权进行此操作,权限不足",
|
||||
"message": "No permission to perform this operation, insufficient permissions",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
@@ -107,7 +107,7 @@ func TokenAuth() func(c *gin.Context) {
|
||||
}
|
||||
if token.Subnet != nil && *token.Subnet != "" {
|
||||
if !network.IsIpInSubnets(ctx, c.ClientIP(), *token.Subnet) {
|
||||
abortWithMessage(c, http.StatusForbidden, fmt.Sprintf("该令牌只能在指定网段使用:%s,当前 ip:%s", *token.Subnet, c.ClientIP()))
|
||||
abortWithMessage(c, http.StatusForbidden, fmt.Sprintf("该API Keys只能在指定网段使用:%s,当前 ip:%s", *token.Subnet, c.ClientIP()))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TokenAuth() func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if !userEnabled || blacklist.IsUserBanned(token.UserId) {
|
||||
abortWithMessage(c, http.StatusForbidden, "用户已被封禁")
|
||||
abortWithMessage(c, http.StatusForbidden, "User has been banned")
|
||||
return
|
||||
}
|
||||
requestModel, err := getRequestModel(c)
|
||||
@@ -129,7 +129,7 @@ func TokenAuth() func(c *gin.Context) {
|
||||
if token.Models != nil && *token.Models != "" {
|
||||
c.Set(ctxkey.AvailableModels, *token.Models)
|
||||
if requestModel != "" && !isModelInList(requestModel, *token.Models) {
|
||||
abortWithMessage(c, http.StatusForbidden, fmt.Sprintf("该令牌无权使用模型:%s", requestModel))
|
||||
abortWithMessage(c, http.StatusForbidden, fmt.Sprintf("该API KeysNone权使用Model:%s", requestModel))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func TokenAuth() func(c *gin.Context) {
|
||||
if model.IsAdmin(token.UserId) {
|
||||
c.Set(ctxkey.SpecificChannelId, parts[1])
|
||||
} else {
|
||||
abortWithMessage(c, http.StatusForbidden, "普通用户不支持指定渠道")
|
||||
abortWithMessage(c, http.StatusForbidden, "Ordinary users do not support specifying channels")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,16 +30,16 @@ func Distribute() func(c *gin.Context) {
|
||||
if ok {
|
||||
id, err := strconv.Atoi(channelId.(string))
|
||||
if err != nil {
|
||||
abortWithMessage(c, http.StatusBadRequest, "无效的渠道 Id")
|
||||
abortWithMessage(c, http.StatusBadRequest, "None效的Channel Id")
|
||||
return
|
||||
}
|
||||
channel, err = model.GetChannelById(id, true)
|
||||
if err != nil {
|
||||
abortWithMessage(c, http.StatusBadRequest, "无效的渠道 Id")
|
||||
abortWithMessage(c, http.StatusBadRequest, "None效的Channel Id")
|
||||
return
|
||||
}
|
||||
if channel.Status != model.ChannelStatusEnabled {
|
||||
abortWithMessage(c, http.StatusForbidden, "该渠道已被禁用")
|
||||
abortWithMessage(c, http.StatusForbidden, "The channel has been disabled")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -47,10 +47,10 @@ func Distribute() func(c *gin.Context) {
|
||||
var err error
|
||||
channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, requestModel, false)
|
||||
if err != nil {
|
||||
message := fmt.Sprintf("当前分组 %s 下对于模型 %s 无可用渠道", userGroup, requestModel)
|
||||
message := fmt.Sprintf("当前Group %s 下对于Model %s No available channels", userGroup, requestModel)
|
||||
if channel != nil {
|
||||
logger.SysError(fmt.Sprintf("渠道不存在:%d", channel.Id))
|
||||
message = "数据库一致性已被破坏,请联系管理员"
|
||||
logger.SysError(fmt.Sprintf("Channel does not exist: %d", channel.Id))
|
||||
message = "Database consistency has been broken, please contact the administrator"
|
||||
}
|
||||
abortWithMessage(c, http.StatusServiceUnavailable, message)
|
||||
return
|
||||
|
||||
@@ -27,7 +27,7 @@ func TurnstileCheck() gin.HandlerFunc {
|
||||
if response == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "Turnstile token 为空",
|
||||
"message": "Turnstile token is empty",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
@@ -61,7 +61,7 @@ func TurnstileCheck() gin.HandlerFunc {
|
||||
if !res.Success {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "Turnstile 校验失败,请刷新重试!",
|
||||
"message": "Turnstile verification failed, please refresh and try again!",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
@@ -70,7 +70,7 @@ func TurnstileCheck() gin.HandlerFunc {
|
||||
err = session.Save()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "无法保存会话信息,请重试",
|
||||
"message": "Unable to save session information, please try again",
|
||||
"success": false,
|
||||
})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user