javascript - How to properly update electron application menu labels? -
i'm trying add translate support on electron application, i've encountered problems when updating application menu. mention development done & tested on macos, i'm willing working on windows too.
i understand menu feature can managed in main process, i'm using ipcmain & ipcrenderer communicate between main & renderer process.
the problem i'm updating 1 label, seems updated (shown in logs) not update in rendered menu.
//menu.getapplicationmenu() in english mainmenu.language = "nl_nl"; //updating 1 label mainmenu.object.items[0].submenu.items[0].label =i18n.__({phrase: 'hello', locale: mainmenu.language}), menu.setapplicationmenu(mainmenu.object); let currentmenu = menu.getapplicationmenu(); //currentmenu reflects change rendered menu still shows old value (english)
i think missing menu.buildfromtemplate(mainmenu.object).
to use menu.setapplicationmenu(template) first need run menu.buildfromtemplate(mainmenu.object) on template convert menu.setapplicationmenu(template) can pick up.
it this:

Comments
Post a Comment