Skip to content

Commit 0f16580

Browse files
laijinhangcg33
authored andcommitted
switch language on the front end
1 parent 62a5a5a commit 0f16580

File tree

9 files changed

+35
-16
lines changed

9 files changed

+35
-16
lines changed

examples/gin/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737
Port: "3306",
3838
User: "root",
3939
Pwd: "root",
40-
Name: "godmin",
40+
Name: "goadmin",
4141
MaxIdleCon: 50,
4242
MaxOpenCon: 150,
4343
Driver: config.DriverMysql,

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ require (
77
github.com/GoAdminGroup/html v0.0.1
88
github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e
99
github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e
10+
github.com/gin-gonic/gin v1.5.0
1011
github.com/go-sql-driver/mysql v1.5.0
12+
github.com/gogf/gf v1.11.6
1113
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
1214
github.com/lib/pq v1.3.0
1315
github.com/magiconair/properties v1.8.1

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5E
77
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
88
github.com/GoAdminGroup/html v0.0.1 h1:SdWNWl4OKPsvDk2GDp5ZKD6ceWoN8n4Pj6cUYxavUd0=
99
github.com/GoAdminGroup/html v0.0.1/go.mod h1:A1laTJaOx8sQ64p2dE8IqtstDeCNBHEazrEp7hR5VvM=
10+
github.com/GoAdminGroup/themes v0.0.27 h1:mm1JBSF2ucK8Yv2PH5w4+gzqisIPo2Q9t4+ICn8460M=
11+
github.com/GoAdminGroup/themes v0.0.27/go.mod h1:ABCOeBeibfg9DxAsGVa1NzYK9/nIbHT/BuFrCRIKo8A=
1012
github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e h1:n+DcnTNkQnHlwpsrHoQtkrJIO7CBx029fw6oR4vIob4=
1113
github.com/NebulousLabs/fastrand v0.0.0-20181203155948-6fb6489aac4e/go.mod h1:Bdzq+51GR4/0DIhaICZEOm+OHvXGwwB2trKZ8B4Y6eQ=
1214
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
@@ -87,6 +89,8 @@ github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW
8789
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
8890
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
8991
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
92+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
93+
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
9094
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
9195
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
9296
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@@ -180,6 +184,8 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h
180184
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
181185
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
182186
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
187+
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
188+
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
183189
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c h1:jceGD5YNJGgGMkJz79agzOln1K9TaZUjv5ird16qniQ=
184190
golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
185191
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

modules/language/cn.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,4 +442,6 @@ var cn = LangSet{
442442
"admin.basic admin": "基础Admin",
443443
"admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "一个内置GoAdmin插件,帮助您快速搭建curd简易管理后台。",
444444
"admin.official": "GoAdmin官方",
445+
446+
"language": "语言",
445447
}

modules/language/en.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,5 @@ var en = LangSet{
405405
"admin.basic admin": "Basic Admin",
406406
"admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "A built-in plugins of GoAdmin which help you to build a crud manager platform quickly.",
407407
"admin.official": "Official",
408+
"language": "Language",
408409
}

modules/language/jp.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,10 @@ var jp = LangSet{
416416
"admin.basic admin": "Basic Admin",
417417
"admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "A built-in plugins of GoAdmin which help you to build a crud manager platform quickly.",
418418
"admin.official": "Official",
419+
420+
"used for login": "ログインに使用",
421+
"used to display": "表示に使用",
422+
"a path a line": "パスの文字列",
423+
424+
"language": "言語",
419425
}

modules/language/tc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,5 @@ var tc = LangSet{
434434
"admin.basic admin": "基礎Admin",
435435
"admin.a built-in plugins of goadmin which help you to build a crud manager platform quickly.": "壹個內置GoAdmin插件,幫助您快速搭建curd簡易管理後臺。",
436436
"admin.official": "GoAdmin官方",
437+
"language": "語言",
437438
}

plugins/admin/controller/edit.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"net/url"
88

9+
"github.com/GoAdminGroup/go-admin/modules/language"
910
"github.com/GoAdminGroup/go-admin/modules/logger"
1011

1112
"github.com/GoAdminGroup/go-admin/template"
@@ -14,10 +15,7 @@ import (
1415

1516
"github.com/GoAdminGroup/go-admin/context"
1617
"github.com/GoAdminGroup/go-admin/modules/auth"
17-
"github.com/GoAdminGroup/go-admin/modules/config"
1818
"github.com/GoAdminGroup/go-admin/modules/file"
19-
"github.com/GoAdminGroup/go-admin/modules/language"
20-
"github.com/GoAdminGroup/go-admin/plugins/admin/models"
2119
"github.com/GoAdminGroup/go-admin/plugins/admin/modules"
2220
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/constant"
2321
form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form"
@@ -230,15 +228,3 @@ func (h *Handler) EditForm(ctx *context.Context) {
230228
ctx.HTML(http.StatusOK, buf.String())
231229
ctx.AddHeader(constant.PjaxUrlHeader, param.PreviousPath)
232230
}
233-
234-
func (h *Handler) SetLanguage(ctx *context.Context) {
235-
if len(ctx.PostForm()["language"]) == 0 {
236-
return
237-
}
238-
if user, ok := ctx.UserValue["user"].(models.UserModel); ok {
239-
config.SetUserConfig(config.UserConfig{
240-
UserId: user.Id,
241-
Language: ctx.PostForm()["language"][0],
242-
})
243-
}
244-
}

plugins/admin/modules/table/generators.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,21 @@ func (s *SystemTable) GetNormalManagerTable(ctx *context.Context) (managerTable
450450
FieldDisplay(func(value types.FieldModel) interface{} {
451451
return ""
452452
})
453+
m := []types.FieldOption{}
454+
m = append(m, types.FieldOption{
455+
Text: language.CN,
456+
Value: "zh",
457+
}, types.FieldOption{
458+
Text: language.EN,
459+
Value: "en",
460+
}, types.FieldOption{
461+
Text: language.JP,
462+
Value: "jp",
463+
}, types.FieldOption{
464+
Text: language.TC,
465+
Value: "tc",
466+
})
467+
formList.AddField(lg("language"), "language", db.Varchar, form.SelectSingle).FieldOptions(m).FieldNotAllowAdd()
453468

454469
formList.SetTable("goadmin_users").SetTitle(lg("Managers")).SetDescription(lg("Managers"))
455470
formList.SetUpdateFn(func(values form2.Values) error {

0 commit comments

Comments
 (0)