Skip to content

Load the translation catalog in main, and translate the menu and dialog titles #623

Closed

Description

@ryanwelcher

Part of #622. Needs #584. Blocks #625, #627, #628 and #629.

Why

Several modules build their sentences in main and send them to the renderer, and some of those modules run in both processes (pr-checkout.cjs, legacy-site.cjs, merge-in-progress.cjs, wporg-handle.cjs, patch-provenance.cjs, project-type.cjs). Without a catalog in main, wrapping them gives a translated screen showing English sentences from main. Keep the code mappings that exist (prCheckoutRefusal, ticket-trunk-notice.cjs); don't turn the rest into codes.

What to do

  1. Move the body of the i18n:locale handler in src/main.js into one memoised localeReply(). The handler returns it, and whenReady awaits it and applies it in main.
  2. Apply it with applyLocale() from src/renderer/locale-setup.cjs, passing setLocaleData from @wordpress/i18n and addFilter from @wordpress/hooks. It has no DOM dependency, and the en-XA filters then cover main's strings too.
  3. That call must run before Menu.setApplicationMenu and createWindow().
  4. Wrap the two labels in src/menu.js ("Open App Log", "Show Logs Folder"). Leave Electron's role menus alone. Translating those means writing every submenu by hand; that's a separate issue if anyone wants it.
  5. Wrap the native dialog titles and filter names in main.js: the save-patch dialog (about line 1036), "Choose a patch file" (about 2390) and "Choose the application to open this folder in" (about 3299).

About 10 strings.

Tests

  • tests/unit/menu.test.cjs: labels with a pseudo filter.
  • tests/unit/ipc-wiring.test.cjs: the handler and main apply the same reply, resolved once.
  • Journey: launch with lang: 'en-XA'. Read the Help menu labels with app.evaluate(({ Menu }) => …). Replace dialog.showOpenDialog the way answerFileDialog does and check the title it was given.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions