i18n: Translate all Chinese to English across the codebase

Translate Chinese comments, log/error messages, validator labels and
Swagger annotations to English throughout the source code, generated
Swagger docs, config files and CI workflows.

Make the English README primary: README.md now holds the English docs
and README_EN.md holds the Chinese version, with cross-language links
updated accordingly.

Note: the generated docs/ swagger files were translated in place; run
`go generate ./...` (swag init) to regenerate them from the now-English
annotations when a Go toolchain is available.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 12:17:04 +02:00
co-authored by Claude Opus 4.8
parent c5687e1506
commit 16e97c8efa
103 changed files with 3088 additions and 3086 deletions
+18 -18
View File
@@ -65,37 +65,37 @@ func (o *Oauth) OidcAuthQueryPre(c *gin.Context) (*model.User, *model.UserToken)
var ut *model.UserToken
q := &api.OidcAuthQuery{}
// 解析查询参数并处理错误
// parse query parameters and handle errors
if err := c.ShouldBindQuery(q); err != nil {
response.Error(c, response.TranslateMsg(c, "ParamsError")+": "+err.Error())
return nil, nil
}
// 获取 OAuth 缓存
// get OAuth cache
v := service.AllService.OauthService.GetOauthCache(q.Code)
if v == nil {
response.Error(c, response.TranslateMsg(c, "OauthExpired"))
return nil, nil
}
// 如果 UserId 为 0,说明还在授权中
// if UserId is 0, authorization is still in progress
if v.UserId == 0 {
//fix: 1.4.2 webclient oidc
c.JSON(http.StatusOK, gin.H{"message": "Authorization in progress, please login and bind", "error": "No authed oidc is found"})
return nil, nil
}
// 获取用户信息
// get user info
u = service.AllService.UserService.InfoById(v.UserId)
if u == nil {
response.Error(c, response.TranslateMsg(c, "UserNotFound"))
return nil, nil
}
// 删除 OAuth 缓存
// delete OAuth cache
service.AllService.OauthService.DeleteOauthCache(q.Code)
// 创建登录日志并生成用户令牌
// create a login log and generate a user token
ut = service.AllService.UserService.Login(u, &model.LoginLog{
UserId: u.Id,
Client: v.DeviceType,
@@ -111,7 +111,7 @@ func (o *Oauth) OidcAuthQueryPre(c *gin.Context) (*model.User, *model.UserToken)
return nil, nil
}
// 返回用户令牌
// return user token
return u, ut
}
@@ -136,7 +136,7 @@ func (o *Oauth) OidcAuthQuery(c *gin.Context) {
})
}
// OauthCallback 回调
// OauthCallback callback
// @Tags Oauth
// @Summary OauthCallback
// @Description OauthCallback
@@ -156,7 +156,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
}
cacheKey := state
oauthService := service.AllService.OauthService
//从缓存中获取
//get from cache
oauthCache := oauthService.GetOauthCache(cacheKey)
if oauthCache == nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -169,7 +169,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
action := oauthCache.Action
verifier := oauthCache.Verifier
var user *model.User
// 获取用户信息
// get user info
code := c.Query("code")
err, oauthUser := oauthService.Callback(code, verifier, op, nonce)
if err != nil {
@@ -184,7 +184,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
if action == service.OauthActionTypeBind {
//fmt.Println("bind", ty, userData)
// 检查此openid是否已经绑定过
// check whether this openid has already been bound
utr := oauthService.UserThirdInfo(op, openid)
if utr.UserId > 0 {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -192,7 +192,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
})
return
}
//绑定
//bind
user = service.AllService.UserService.InfoById(userId)
if user == nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -200,7 +200,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
})
return
}
//绑定
//bind
err := oauthService.BindOauthUser(userId, oauthUser, op)
if err != nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -214,7 +214,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
return
} else if action == service.OauthActionTypeLogin {
//登录
//login
if userId != 0 {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
"message": "OauthHasBeenSuccess",
@@ -225,13 +225,13 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
if user == nil {
oauthConfig := oauthService.InfoByOp(op)
if !*oauthConfig.AutoRegister {
//c.String(http.StatusInternalServerError, "还未绑定用户,请先绑定")
//c.String(http.StatusInternalServerError, "not yet bound to a user, please bind first")
oauthCache.UpdateFromOauthUser(oauthUser)
c.Redirect(http.StatusFound, "/_admin/#/oauth/bind/"+cacheKey)
return
}
//自动注册
//auto register
err, user = service.AllService.UserService.RegisterByOauth(oauthUser, op)
if err != nil {
c.HTML(http.StatusOK, "oauth_fail.html", gin.H{
@@ -242,7 +242,7 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
}
oauthCache.UserId = user.Id
oauthService.SetOauthCache(cacheKey, oauthCache, 0)
// 如果是webadmin,登录成功后跳转到webadmin
// if it is webadmin, after successful login redirect to webadmin
if oauthCache.DeviceType == model.LoginLogClientWebAdmin {
/*service.AllService.UserService.Login(u, &model.LoginLog{
UserId: u.Id,
@@ -299,7 +299,7 @@ func (o *Oauth) Message(c *gin.Context) {
}
}
//返回js内容
//returnjscontent
c.Header("Content-Type", "application/javascript")
c.String(http.StatusOK, res)
}