mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-08 17:53:41 +08:00
fix: translate error messages and comments to English for consistency
This commit is contained in:
@@ -53,7 +53,7 @@ func getLarkUserInfoByCode(code string) (*LarkUser, error) {
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.SysLog(err.Error())
|
||||
return nil, errors.New("None法连接至飞书服务器,请稍后Retry!")
|
||||
return nil, errors.New("Unable to connect to Lark server, please try again later!")
|
||||
}
|
||||
defer res.Body.Close()
|
||||
var oAuthResponse LarkOAuthResponse
|
||||
@@ -69,7 +69,7 @@ func getLarkUserInfoByCode(code string) (*LarkUser, error) {
|
||||
res2, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.SysLog(err.Error())
|
||||
return nil, errors.New("None法连接至飞书服务器,请稍后Retry!")
|
||||
return nil, errors.New("Unable to connect to Lark server, please try again later!")
|
||||
}
|
||||
var larkUser LarkUser
|
||||
err = json.NewDecoder(res2.Body).Decode(&larkUser)
|
||||
@@ -168,7 +168,7 @@ func LarkBind(c *gin.Context) {
|
||||
if model.IsLarkIdAlreadyTaken(user.LarkId) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "该飞书账户已被Bind",
|
||||
"message": "This Lark account has already been bound",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,15 +5,16 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/logger"
|
||||
"github.com/songquanpeng/one-api/controller"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type OidcResponse struct {
|
||||
@@ -60,7 +61,7 @@ func getOidcUserInfoByCode(code string) (*OidcUser, error) {
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.SysLog(err.Error())
|
||||
return nil, errors.New("None法连接至 OIDC 服务器,请稍后Retry!")
|
||||
return nil, errors.New("Unable to connect to the OIDC server, please try again later!")
|
||||
}
|
||||
defer res.Body.Close()
|
||||
var oidcResponse OidcResponse
|
||||
@@ -76,7 +77,7 @@ func getOidcUserInfoByCode(code string) (*OidcUser, error) {
|
||||
res2, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.SysLog(err.Error())
|
||||
return nil, errors.New("None法连接至 OIDC 服务器,请稍后Retry!")
|
||||
return nil, errors.New("Unable to connect to the OIDC server, please try again later!")
|
||||
}
|
||||
var oidcUser OidcUser
|
||||
err = json.NewDecoder(res2.Body).Decode(&oidcUser)
|
||||
@@ -104,7 +105,7 @@ func OidcAuth(c *gin.Context) {
|
||||
if !config.OidcEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "Administrator未开启通过 OIDC Log in以及Sign up",
|
||||
"message": "Administrator has not enabled OIDC Log in and Sign up",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -173,7 +174,7 @@ func OidcBind(c *gin.Context) {
|
||||
if !config.OidcEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "Administrator未开启通过 OIDC Log in以及Sign up",
|
||||
"message": "The administrator has turned off new user registration",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -192,7 +193,7 @@ func OidcBind(c *gin.Context) {
|
||||
if model.IsOidcIdAlreadyTaken(user.OidcId) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "该 OIDC 账户已被Bind",
|
||||
"message": "This OIDC account has already been bound",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ package controller
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/message"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/message"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
)
|
||||
|
||||
func GetStatus(c *gin.Context) {
|
||||
@@ -100,7 +100,7 @@ func SendEmailVerification(c *gin.Context) {
|
||||
if !allowed {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "AdministratorEnable了邮箱域名白名单,您的Email address的域名不在白名单中",
|
||||
"message": "Administrator has enabled email domain whitelist, your email domain is not in the whitelist",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -154,8 +154,8 @@ func SendPasswordResetEmail(c *gin.Context) {
|
||||
link := fmt.Sprintf("%s/user/reset?email=%s&token=%s", config.ServerAddress, email, code)
|
||||
subject := fmt.Sprintf("%s Password reset", config.SystemName)
|
||||
content := fmt.Sprintf("<p>Hello, you are resetting %s password.</p>"+
|
||||
"<p>点击 <a href='%s'>此处</a> 进行Password reset。</p>"+
|
||||
"<p>如果链接None法点击,请尝试点击下面的链接或将其Copy到浏览器中打开:<br> %s </p>"+
|
||||
"<p>Click <a href='%s'>here</a> to reset your password.</p>"+
|
||||
"<p>If the link cannot be clicked, please try clicking the link below or copy it to your browser to open:<br> %s </p>"+
|
||||
"<p>The reset link is valid within %d minutes. If it is not your operation, please ignore it.</p>", config.SystemName, link, link, common.VerificationValidMinutes)
|
||||
err := message.SendEmail(subject, email, content)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,13 +2,13 @@ package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/helper"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/helper"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
)
|
||||
|
||||
func GetOptions(c *gin.Context) {
|
||||
@@ -47,7 +47,7 @@ func UpdateOption(c *gin.Context) {
|
||||
if !config.ValidThemes[option.Value] {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "None效的主题",
|
||||
"message": "invalid theme",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func UpdateOption(c *gin.Context) {
|
||||
if option.Value == "true" && config.GitHubClientId == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "None法Enable GitHub OAuth,请先填入 GitHub Client Id 以及 GitHub Client Secret!",
|
||||
"message": "Unable to enable GitHub OAuth, please fill in the GitHub Client Id and GitHub Client Secret first!",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func UpdateOption(c *gin.Context) {
|
||||
if option.Value == "true" && len(config.EmailDomainWhitelist) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "None法Enable邮箱域名限制,请先填入限制的邮箱域名!",
|
||||
"message": "Unable to enable email domain restriction, please fill in the restricted email domains first!",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func AddToken(c *gin.Context) {
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": fmt.Sprintf("参数Error:%s", err.Error()),
|
||||
"message": fmt.Sprintf("invalid token: %s", err.Error()),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -336,7 +336,7 @@ func UpdateToken(c *gin.Context) {
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": fmt.Sprintf("参数Error:%s", err.Error()),
|
||||
"message": fmt.Sprintf("invalid token: %s", err.Error()),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ func GetUserDashboard(c *gin.Context) {
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "None法获取Statistics",
|
||||
"message": "Failed to get user dashboard data: " + err.Error(),
|
||||
"data": nil,
|
||||
})
|
||||
return
|
||||
@@ -415,7 +415,7 @@ func UpdateUser(c *gin.Context) {
|
||||
if myRole <= updatedUser.Role && myRole != model.RoleRootUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "None权将其他Users权限等级Promote到大于Equals自己的权限等级",
|
||||
"message": "No permission to promote other users to a permission level greater than or equal to your own",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -529,7 +529,7 @@ func DeleteSelf(c *gin.Context) {
|
||||
if user.Role == model.RoleRootUser {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "不能DeleteSuper administrator账户",
|
||||
"message": "Cannot delete super administrator account",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -813,7 +813,7 @@ func AdminTopUp(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if req.Remark == "" {
|
||||
req.Remark = fmt.Sprintf("通过 API Recharge %s", common.LogQuota(int64(req.Quota)))
|
||||
req.Remark = fmt.Sprintf("Recharged via API %s", common.LogQuota(int64(req.Quota)))
|
||||
}
|
||||
model.RecordTopupLog(req.UserId, req.Remark, req.Quota)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user