Skip to content

Commit

Permalink
chore: fix i18next warnings (appium#1574)
Browse files Browse the repository at this point in the history
  • Loading branch information
eglitise authored and sudharsan-selvaraj committed Aug 19, 2024
1 parent 9e5b87d commit ad2e235
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/common/shared/i18next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function getI18NextOptions(backend) {
escapeValue: false,
},
lng: (settings && settings.getSync('PREFERRED_LANGUAGE')) || fallbackLng,
load: 'currentOnly',
fallbackLng,
supportedLngs: languageList.map((language) => language.code),
};
Expand Down
12 changes: 10 additions & 2 deletions app/electron/main/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,17 @@ export function setupMainWindow() {
]).popup(mainWindow);
});

i18n.on('initialized', () => {
rebuildMenus(mainWindow);
i18n.off('initialized');
});

i18n.on('languageChanged', async (languageCode) => {
// this event gets called before the i18n initialization event,
// so add a guard condition
if (!i18n.isInitialized) {
return;
}
rebuildMenus(mainWindow);
await settings.set('PREFERRED_LANGUAGE', languageCode);
webContents.getAllWebContents().forEach((wc) => {
Expand All @@ -102,8 +112,6 @@ export function setupMainWindow() {
});
});
});

rebuildMenus(mainWindow);
}

export function launchNewSessionWindow() {
Expand Down

0 comments on commit ad2e235

Please sign in to comment.