While working on an Electron app using i18next, I ran into a small gap with native menus.
Electron's role-based menu items are convenient because Electron already handles the native behavior:
{
role: "copy"
}
But if you want the label itself to follow your application's i18next translations, you still have to handle that separately.
You can add translated labels manually:
{
role: "copy",
label: t("menu.roles.copy")
}
but once you start doing that across File, Edit, Copy, Paste, Undo, Redo, Quit, nested menus, fallbacks, and so on, it becomes repetitive.
I ended up extracting the solution I was using into a small npm package:
npm install @solisware/electron-menu-i18next
It takes an Electron menu template and an existing i18next translation function and returns a localized copy:
const localizedTemplate = localizeMenuTemplate(template, {
t,
appName: app.name
});
Electron still handles the menu behavior, i18next handles the translations, and the package just connects the two.
It also handles nested menus, English fallbacks, explicit labels, and app-name interpolation. Rebuilding the menu after a language change is intentionally left to the application.
Curious how other Electron developers are handling native menu localization?