@@ -203,14 +203,19 @@ func GetGlobalMenu(user models.UserModel, conn db.Connection, lang string, plugi
203203 var title string
204204 for i := 0 ; i < len (menus ); i ++ {
205205
206- title = language .GetWithLang (menus [i ]["title" ].(string ), lang )
206+ if menus [i ]["type" ].(int64 ) == 1 {
207+ title = language .GetUser (menus [i ]["title" ].(string ), user .Id )
208+ } else {
209+ title = language .GetWithLang (menus [i ]["title" ].(string ), lang )
210+ }
211+
207212 menuOption = append (menuOption , map [string ]string {
208213 "id" : strconv .FormatInt (menus [i ]["id" ].(int64 ), 10 ),
209214 "title" : title ,
210215 })
211216 }
212217
213- menuList := constructMenuTree (menus , 0 , lang )
218+ menuList := constructMenuTree (menus , 0 , lang , user . Id )
214219 maxOrder := int64 (0 )
215220 if len (menus ) > 0 {
216221 maxOrder = menus [len (menus )- 1 ]["parent_id" ].(int64 )
@@ -224,15 +229,16 @@ func GetGlobalMenu(user models.UserModel, conn db.Connection, lang string, plugi
224229 }
225230}
226231
227- func constructMenuTree (menus []map [string ]interface {}, parentID int64 , lang string ) []Item {
232+ func constructMenuTree (menus []map [string ]interface {}, parentID int64 , lang string , uid int64 ) []Item {
228233
229234 branch := make ([]Item , 0 )
230235
231236 var title string
232237 for j := 0 ; j < len (menus ); j ++ {
233238 if parentID == menus [j ]["parent_id" ].(int64 ) {
239+
234240 if menus [j ]["type" ].(int64 ) == 1 {
235- title = language .Get (menus [j ]["title" ].(string ))
241+ title = language .GetUser (menus [j ]["title" ].(string ), uid )
236242 } else {
237243 title = menus [j ]["title" ].(string )
238244 }
@@ -256,7 +262,7 @@ func constructMenuTree(menus []map[string]interface{}, parentID int64, lang stri
256262 Icon : menus [j ]["icon" ].(string ),
257263 Header : header ,
258264 Active : "" ,
259- ChildrenList : constructMenuTree (menus , menus [j ]["id" ].(int64 ), lang ),
265+ ChildrenList : constructMenuTree (menus , menus [j ]["id" ].(int64 ), lang , uid ),
260266 }
261267
262268 branch = append (branch , child )
0 commit comments