Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] login page i18n bug #216

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[fix] login page i18n bug
  • Loading branch information
trheyi committed Oct 20, 2022
commit 8ce40a2bfef2474e3da963a7c8aa5fb6f18dc787
14 changes: 10 additions & 4 deletions widgets/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/yaoapp/gou"
"github.com/yaoapp/gou/session"
"github.com/yaoapp/kun/exception"
"github.com/yaoapp/kun/log"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/data"
"github.com/yaoapp/yao/i18n"
Expand Down Expand Up @@ -445,7 +446,11 @@ func processXgen(process *gou.Process) interface{} {
// Translate
newLayout, err := i18n.Trans(process.Lang(config.Conf.Lang), []string{"login.admin"}, layout)
if err != nil {
layout = newLayout.(map[string]interface{})
log.Error("[Login] Xgen i18n.Trans login.admin %s", err.Error())
}

if new, ok := newLayout.(map[string]interface{}); ok {
layout = new
}

xgenLogin["entry"]["admin"] = admin.Layout.Entry
Expand All @@ -454,7 +459,6 @@ func processXgen(process *gou.Process) interface{} {
"login": "/api/__yao/login/admin",
"layout": layout,
}

}

if user, has := login.Logins["user"]; has {
Expand All @@ -474,16 +478,18 @@ func processXgen(process *gou.Process) interface{} {
// Translate
newLayout, err := i18n.Trans(process.Lang(config.Conf.Lang), []string{"login.user"}, layout)
if err != nil {
layout = newLayout.(map[string]interface{})
log.Error("[Login] Xgen %s", err.Error())
}

if new, ok := newLayout.(map[string]interface{}); ok {
layout = new
}
xgenLogin["entry"]["user"] = user.Layout.Entry
xgenLogin["user"] = map[string]interface{}{
"captcha": "/api/__yao/login/user/captcha?type=digit",
"login": "/api/__yao/login/user",
"layout": layout,
}
xgenLogin["layout"] = layout
}

xgenSetting := map[string]interface{}{
Expand Down
3 changes: 2 additions & 1 deletion widgets/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ func TestProcessXgen(t *testing.T) {
assert.Equal(t, "/x/Table/pet", xgen.Get("login.entry.user"))
assert.Equal(t, "/api/__yao/login/user/captcha?type=digit", xgen.Get("login.user.captcha"))
assert.Equal(t, "/api/__yao/login/user", xgen.Get("login.user.login"))
assert.Equal(t, "/assets/images/login/cover.svg", xgen.Get("login.layout.cover"))
assert.Equal(t, "/assets/images/login/cover.svg", xgen.Get("login.user.layout.cover"))
assert.Equal(t, "/assets/images/login/cover.svg", xgen.Get("login.admin.layout.cover"))
assert.Equal(t, "/api/__yao/app/icons/app.ico", xgen.Get("favicon"))
assert.Equal(t, "/api/__yao/app/icons/app.png", xgen.Get("logo"))
assert.Equal(t, os.Getenv("YAO_ENV"), xgen.Get("mode"))
Expand Down