diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index fd85c075..35e9d247 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -200,6 +200,10 @@ export class WindowHandler { this.mainWindow.webContents.on('did-stop-loading', async () => { if (this.mainWindow && windowExists(this.mainWindow)) { + this.mainWindow.webContents.send('page-load-failed', { + locale: i18n.getLocale(), + resources: i18n.loadedResources, + }); const href = await this.mainWindow.webContents.executeJavaScript('document.location.href'); try { if (href === 'data:text/html,chromewebdata' || href === 'chrome-error://chromewebdata/') { diff --git a/src/common/i18n.ts b/src/common/i18n.ts index 0bf871e7..df3c441b 100644 --- a/src/common/i18n.ts +++ b/src/common/i18n.ts @@ -35,6 +35,9 @@ class Translation { } this.locale = locale; + if (!this.loadedResources[this.locale]) { + this.loadResource(this.locale); + } } /** diff --git a/src/renderer/components/windows-title-bar.tsx b/src/renderer/components/windows-title-bar.tsx index eadf4b0f..4abd70cc 100644 --- a/src/renderer/components/windows-title-bar.tsx +++ b/src/renderer/components/windows-title-bar.tsx @@ -54,13 +54,6 @@ export default class WindowsTitleBar extends React.Component<{}, IState> { } } - public componentWillMount() { - this.window.removeListener('maximize', this.updateState); - this.window.removeListener('unmaximize', this.updateState); - this.window.removeListener('enter-full-screen', this.updateState); - this.window.removeListener('leave-full-screen', this.updateState); - } - public componentWillUnmount(): void { if (this.observer) { this.observer.disconnect(); diff --git a/src/renderer/preload-main.ts b/src/renderer/preload-main.ts index ee8e21f5..3a4a68b2 100644 --- a/src/renderer/preload-main.ts +++ b/src/renderer/preload-main.ts @@ -86,6 +86,11 @@ ipcRenderer.on('page-load', (_event, { locale, resources, enableCustomTitleBar, } }); +// When the window fails to load +ipcRenderer.on('page-load-failed', (_event, { locale, resources }) => { + i18n.setResource(locale, resources); +}); + // Injects network error content into the DOM ipcRenderer.on('network-error', (_event, { error }) => { const networkErrorContainer = document.createElement( 'div' );