Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Localizing Electron Menus with i18next—Why I Built electron-menu-i18next

Description and use

The @solisware/electron-menu-i18next package automatically localizes Electron role-based menu items with i18next, preserving native behavior and reducing boilerplate.

Problem

Electron’s role-based native menu items don’t integrate directly with an i18next instance running in the main process, making it hard to provide translated labels while preserving native behavior.

Outcome

The package eliminates repetitive code for translating Electron menu roles, provides English fallbacks, respects explicit labels, and handles platform differences, enabling developers to localize menus with minimal effort.

Workflow

  • Define an Electron menu template using role properties only.
  • Pass the template and the i18next translation function to localizeMenuTemplate().
  • The package recursively replaces role-based items with translated labels, using built-in English fallbacks and respecting explicit labels.
  • Electron builds the native menu from the localized template.
  • When the application language changes, rebuild the menu at the application level using the same process.
  • The menu now displays translated labels while maintaining native role behavior.

Evidence

Electron’s role-based native menu items don’t integrate directly with an i18next instance running in the main process

Source

The idea is deliberately simple. Give it an Electron menu template and your existing i18next translation function, and it localizes role-based menu items before Electron builds the native menu.

Source

One was handling fallback. I didn't think somebody should need a perfectly complete translation file before using the package, so it includes built-in English labels for Electron roles.

Source

  • Record date: 2026-10-03T23:41:21.531Z