Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix i18next warnings #1574

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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