Forgot to add locale
*I'm really starting to hate typescript*
This commit is contained in:
parent
a535ec0a8a
commit
3d90479cba
3 changed files with 21 additions and 6 deletions
|
@ -14,6 +14,7 @@ export class AppEvents {
|
|||
private store: any = undefined;
|
||||
private win: any = undefined;
|
||||
private tray: any = undefined;
|
||||
private i18n: any = undefined;
|
||||
|
||||
constructor(store: any) {
|
||||
this.store = store
|
||||
|
@ -112,8 +113,9 @@ export class AppEvents {
|
|||
console.log('[AppEvents] App ready');
|
||||
}
|
||||
|
||||
public bwCreated(win: Electron.BrowserWindow) {
|
||||
public bwCreated(win: Electron.BrowserWindow, i18n: any) {
|
||||
this.win = win
|
||||
this.i18n = i18n
|
||||
|
||||
electron.app.on('open-url', (event, url) => {
|
||||
event.preventDefault()
|
||||
|
@ -226,6 +228,7 @@ export class AppEvents {
|
|||
height: 20
|
||||
}),
|
||||
}
|
||||
console.log(this.i18n)
|
||||
|
||||
this.tray = new electron.Tray(process.platform === 'win32' ? icons.win32 : (process.platform === 'darwin' ? icons.darwin : icons.linux))
|
||||
this.tray.setToolTip(electron.app.getName())
|
||||
|
@ -266,7 +269,7 @@ export class AppEvents {
|
|||
|
||||
const menu = electron.Menu.buildFromTemplate([
|
||||
{
|
||||
label: (visible ? 'Minimize to Tray' : `Show ${electron.app.getName()}`),
|
||||
label: (visible ? this.i18n['action.tray.minimize'] : `${this.i18n['action.tray.show']} ${electron.app.getName()}`),
|
||||
click: () => {
|
||||
if (this.win) {
|
||||
if (visible) {
|
||||
|
@ -278,7 +281,7 @@ export class AppEvents {
|
|||
}
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
label: this.i18n['action.tray.quit'],
|
||||
click: () => {
|
||||
electron.app.quit()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ export class Win {
|
|||
private app: any | undefined = null;
|
||||
private store: any | undefined = null;
|
||||
private devMode: boolean = !electron.app.isPackaged;
|
||||
public i18n: any = {};
|
||||
|
||||
constructor(app: electron.App, store: any) {
|
||||
this.app = app;
|
||||
|
@ -288,18 +289,29 @@ export class Win {
|
|||
event.returnValue = process.platform;
|
||||
});
|
||||
|
||||
let i18nBase = fs.readFileSync(path.join(__dirname, "../../src/i18n/en_US.jsonc"), "utf8");
|
||||
i18nBase = jsonc.parse(i18nBase)
|
||||
try {
|
||||
let i18n = fs.readFileSync(path.join(__dirname, `../../src/i18n/${this.store.general.language}.jsonc`), "utf8");
|
||||
i18n = jsonc.parse(i18n)
|
||||
this.i18n = Object.assign(i18nBase, i18n)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
electron.ipcMain.on("get-i18n", (event, key) => {
|
||||
let i18nBase = fs.readFileSync(path.join(__dirname, "../../src/i18n/en_US.jsonc"), "utf8");
|
||||
i18nBase = jsonc.parse(i18nBase)
|
||||
try {
|
||||
let i18n = fs.readFileSync(path.join(__dirname, `../../src/i18n/${key}.jsonc`), "utf8");
|
||||
i18n = jsonc.parse(i18n)
|
||||
Object.assign(i18nBase, i18n)
|
||||
this.i18n = Object.assign(i18nBase, i18n)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
event.returnValue = e;
|
||||
}
|
||||
|
||||
|
||||
this.i18n = i18nBase;
|
||||
event.returnValue = i18nBase;
|
||||
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ electron.app.on('ready', () => {
|
|||
|
||||
electron.components.whenReady().then(async () => {
|
||||
win = await Cider.createWindow()
|
||||
App.bwCreated(win);
|
||||
App.bwCreated(win, Cider.i18n);
|
||||
/// please dont change this for plugins to get proper and fully initialized Win objects
|
||||
plug.callPlugins('onReady', win);
|
||||
win.on("ready-to-show", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue