Skip to content

Commit

Permalink
complete language module
Browse files Browse the repository at this point in the history
  • Loading branch information
cg33 committed Sep 9, 2018
1 parent 7f9c08a commit a8b5555
Show file tree
Hide file tree
Showing 23 changed files with 239 additions and 188 deletions.
30 changes: 29 additions & 1 deletion modules/language/cn.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,37 @@ var cn = map[string]string{
"reset": "重置",
"save": "保存",
"edit": "编辑",
"expand": "展开",
"collapse": "折叠",
"online": "在线",
"setting": "设置",
"sign out": "登出",

"operation": "操作",
"permission manage": "权限管理",
"menus manage": "菜单管理",
"roles manage": "角色管理",
"operation log": "操作日志",
"method": "方法",
"input": "输入",
"operation": "操作",

"are you sure to delete": "你确定要删除吗",
"yes": "确定",
"cancel": "取消",

"avatar": "头像",
"password": "密码",
"slug": "标志",
"permission": "权限",
"userid": "用户ID",
"content": "内容",
"parent": "父级",
"icon": "图标",
"uri": "路径",

"admin": "管理",
"users": "用户",
"roles": "角色",
"menu": "菜单",
"dashboard": "仪表盘",
}
67 changes: 48 additions & 19 deletions modules/language/en.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,53 @@
package language

var en = map[string]string{
"managers": "Managers",
"name": "Name",
"nickname": "Nickname",
"role": "Role",
"createdat": "createdAt",
"updatedat": "updatedAt",
"path": "path",
"new": "New",
"action": "Action",
"toggle dropdown": "Toggle Dropdown",
"delete": "Delete",
"refresh": "Refresh",
"back": "Back",
"reset": "Reset",
"save": "Save",
"edit": "Edit",
"operation": "Operation",
"managers": "Managers",
"name": "Name",
"nickname": "Nickname",
"role": "Role",
"createdat": "createdAt",
"updatedat": "updatedAt",
"path": "path",
"new": "New",
"action": "Action",
"toggle dropdown": "Toggle Dropdown",
"delete": "Delete",
"refresh": "Refresh",
"expand": "Expand",
"collapse": "Collapse",
"back": "Back",
"reset": "Reset",
"save": "Save",
"edit": "Edit",
"operation": "Operation",
"method": "Method",
"input": "input",
"online": "Online",
"setting": "Setting",
"sign out": "Sign out",

"are you sure to delete": "Are you sure to delete",
"yes": "yes",
"cancel": "cancel",

"permission manage": "Permission Manage",
"method": "Method",
"input": "input",
"menus manage": "Menus Manage",
"roles manage": "Roles manage",
"operation log": "Operation log",

"avatar": "Avatar",
"password": "Password",
"slug": "Slug",
"permission": "Permission",
"userid": "UserID",
"content": "Content",
"parent": "Parent",
"icon": "Icon",
"uri": "Uri",

"admin": "Admin",
"users": "Users",
"roles": "Roles",
"menu": "Menu",
"dashboard": "Dashboard",
}
20 changes: 18 additions & 2 deletions modules/menu/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/chenhg5/go-admin/modules/connections"
"strconv"
"sync"
"github.com/chenhg5/go-admin/modules/language"
)

type Menu struct {
Expand Down Expand Up @@ -31,10 +32,18 @@ func SetGlobalMenu() {

menuOption := make([]map[string]string, 0)

var title string
for i := 0; i < len(menus); i++ {

if menus[i]["type"].(int64) == 1 {
title = language.Get(menus[i]["title"].(string))
} else {
title = menus[i]["title"].(string)
}

menuOption = append(menuOption, map[string]string{
"id": strconv.FormatInt(menus[i]["id"].(int64), 10),
"title": menus[i]["title"].(string),
"title": title,
})
}

Expand All @@ -53,13 +62,20 @@ func ConstructMenuTree(menus []map[string]interface{}, parentId int64) []MenuIte

branch := make([]MenuItem, 0)

var title string
for j := 0; j < len(menus); j++ {
if parentId == menus[j]["parent_id"].(int64) {

childList := ConstructMenuTree(menus, menus[j]["id"].(int64))

if menus[j]["type"].(int64) == 1 {
title = language.Get(menus[j]["title"].(string))
} else {
title = menus[j]["title"].(string)
}

child := MenuItem{
Name: menus[j]["title"].(string),
Name: title,
ID: strconv.FormatInt(menus[j]["id"].(int64), 10),
Url: menus[j]["uri"].(string),
Icon: menus[j]["icon"].(string),
Expand Down
7 changes: 1 addition & 6 deletions plugins/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package admin
import (
"github.com/chenhg5/go-admin/context"
"github.com/chenhg5/go-admin/modules/config"
"github.com/chenhg5/go-admin/plugins/admin/modules/language"
"github.com/chenhg5/go-admin/plugins/admin/models"
"github.com/chenhg5/go-admin/modules/connections"
"github.com/chenhg5/go-admin/modules/menu"
Expand Down Expand Up @@ -61,8 +60,4 @@ func (admin *Admin) GetRequest() []context.Path {

func (admin *Admin) GetHandler(url, method string) context.Handler {
return plugins.GetHandler(url, method, &admin.app.HandlerList)
}

func (admin *Admin) GetLocales() map[string]string {
return language.Locales[config.Get().LANGUAGE]
}
}
Loading

0 comments on commit a8b5555

Please sign in to comment.