Typescript - Fix i18n locale setting issue

This commit is contained in:
Kiran Niranjan 2019-01-03 14:30:35 +05:30
parent c58678eeb2
commit eeb1ff295e
3 changed files with 7 additions and 5 deletions

View File

@ -199,7 +199,7 @@ export class WindowHandler {
this.mainWindow.webContents.insertCSS(
fs.readFileSync(path.join(__dirname, '..', '/renderer/styles/snack-bar.css'), 'utf8').toString(),
);
this.mainWindow.webContents.send('page-load', { isWindowsOS, resources: i18n.loadedResources });
this.mainWindow.webContents.send('page-load', { isWindowsOS, locale: i18n.getLocale(), resources: i18n.loadedResources });
this.appMenu = new AppMenu();
this.monitorWindowActions();
// Ready to show the window

View File

@ -64,9 +64,11 @@ class Translation {
/**
* Keeps ref of loaded resources from the main process
*
* @param resource
* @param locale {LocaleType}
* @param resource {JSON}
*/
public setResource(resource: JSON): void {
public setResource(locale: LocaleType, resource: JSON): void {
this.locale = locale;
this.loadedResources = resource;
}

View File

@ -38,9 +38,9 @@ const createAPI = () => {
createAPI();
// When the window is completely loaded
ipcRenderer.on('page-load', (_event, { isWindowsOS, resources }) => {
ipcRenderer.on('page-load', (_event, { isWindowsOS, locale, resources }) => {
i18n.setResource(resources);
i18n.setResource(locale, resources);
if (isWindowsOS) {
// injects custom window title bar