const {
app,
BrowserWindow,
session,
ipcMain
} = require("electron");
const backend = require("i18next-electron-fs-backend");
const fs = require("fs");
let win;
async function createWindow() {
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
contextIsolation: true,
preload: path.join(__dirname, "preload.js")
}
});
backend.mainBindings(ipcMain, win, fs); // <- configures the backend
// ...
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== "darwin") {
app.quit();
} else {
i18nextBackend.clearMainBindings(ipcMain);
}
});
2条答案
按热度按时间14ifxucb1#
您可以改用i18 next-electron-fs-backend:https://github.com/reZach/i18next-electron-fs-backend
toe950272#
我是
i18next-electron-fs-backend
的维护者。尝试以下步骤(在secure-electron-template
库中可以找到此包的工作实现)。导入后端
更新预加载脚本
更新主进程
我在不久前报告的an issue中发现,在生产环境中,资源没有正确加载,也许我拥有的i18n.mainconfig.js文件可以帮助您进行特定的修复。
i18n.mainconfig.js