mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
fix: ELECTRON-1488 (Update i18n resources when page fail to load) (#773)
* ELECTRON-1491 - Update i18n when page failed to load * ELECTRON-1491 - Preload i18n resources & remove unwanted code
This commit is contained in:
parent
4a5f7ff77d
commit
b7067fca9a
@ -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/') {
|
||||
|
@ -35,6 +35,9 @@ class Translation {
|
||||
}
|
||||
|
||||
this.locale = locale;
|
||||
if (!this.loadedResources[this.locale]) {
|
||||
this.loadResource(this.locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
@ -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' );
|
||||
|
Loading…
Reference in New Issue
Block a user