Skip to content

Commit

Permalink
Merge pull request #146 from pczyzyk/patch-1
Browse files Browse the repository at this point in the history
Enable i18next translations in newly created windows from Renderer pr…
  • Loading branch information
reZach authored Nov 3, 2023
2 parents dfb2f5d + 6af1020 commit 352dd68
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,15 @@ app.on("web-contents-created", (event, contents) => {
// Disable Node.js integration
webPreferences.nodeIntegration = false;
});

// enable i18next translations in popup window
contents.on("did-create-window", (window) => {
i18nextBackend.mainBindings(ipcMain, window, fs);
});
// destroy bindings on popup window closed
contents.on("destroyed", () => {
i18nextBackend.clearMainBindings(ipcMain);
});

// https://electronjs.org/docs/tutorial/security#13-disable-or-limit-creation-of-new-windows
// This code replaces the old "new-window" event handling;
// https://github.com/electron/electron/pull/24517#issue-447670981
Expand All @@ -291,4 +299,4 @@ app.on("web-contents-created", (event, contents) => {
action: "allow"
};
});
});
});

0 comments on commit 352dd68

Please sign in to comment.