fixed main menu

This commit is contained in:
SPRINX0\prochazka
2025-11-18 13:05:22 +01:00
parent f047ec787a
commit a6763a3e5d
2 changed files with 11 additions and 12 deletions

View File

@@ -1,10 +1,10 @@
function _t(key, { defaultMessage } = {}) {
return global.TRANSLATION_DATA?.[key] || defaultMessage;
function _t(key, { defaultMessage, currentTranslations } = {}) {
return (currentTranslations || global.TRANSLATION_DATA)?.[key] || defaultMessage;
}
module.exports = ({ editMenu, isMac }) => [
module.exports = ({ editMenu, isMac }, currentTranslations = null) => [
{
label: _t('menu.file', { defaultMessage: 'File' }),
label: _t('menu.file', { defaultMessage: 'File', currentTranslations }),
submenu: [
{ command: 'new.connection', hideDisabled: true },
{ command: 'new.sqliteDatabase', hideDisabled: true },
@@ -32,7 +32,7 @@ module.exports = ({ editMenu, isMac }) => [
},
editMenu
? {
label: _t('menu.edit', { defaultMessage: 'Edit' }),
label: _t('menu.edit', { defaultMessage: 'Edit', currentTranslations }),
submenu: [
{ command: 'edit.undo' },
{ command: 'edit.redo' },
@@ -57,7 +57,7 @@ module.exports = ({ editMenu, isMac }) => [
// ],
// },
{
label: _t('menu.view', { defaultMessage: 'View' }),
label: _t('menu.view', { defaultMessage: 'View', currentTranslations }),
submenu: [
{ command: 'app.reload', hideDisabled: true },
{ command: 'app.toggleDevTools', hideDisabled: true },
@@ -79,7 +79,7 @@ module.exports = ({ editMenu, isMac }) => [
],
},
{
label: _t('menu.tools', { defaultMessage: 'Tools' }),
label: _t('menu.tools', { defaultMessage: 'Tools', currentTranslations }),
submenu: [
{ command: 'database.search', hideDisabled: true },
{ command: 'commandPalette.show', hideDisabled: true },
@@ -106,7 +106,7 @@ module.exports = ({ editMenu, isMac }) => [
]
: []),
{
label: _t('menu.help', { defaultMessage: 'Help' }),
label: _t('menu.help', { defaultMessage: 'Help', currentTranslations }),
submenu: [
{ command: 'app.openDocs', hideDisabled: true },
{ command: 'app.openWeb', hideDisabled: true },

View File

@@ -23,7 +23,7 @@
import NewObjectModal from '../modals/NewObjectModal.svelte';
import openNewTab from '../utility/openNewTab';
import { useConfig, usePromoWidget } from '../utility/metadataLoaders';
import { _t } from '../translations';
import { _t, getCurrentTranslations } from '../translations';
let domSettings;
let domCloudAccount;
@@ -153,9 +153,8 @@
const rect = domMainMenu.getBoundingClientRect();
const left = rect.right;
const top = rect.top;
const items = mainMenuDefinition({ editMenu: false });
const copy = items.map(x => x && ({ ...x, label: x?.label ? _t(x.label.id, x.label.defaultMessage) : null }));
currentDropDownMenu.set({ left, top, items: copy });
const items = mainMenuDefinition({ editMenu: false }, getCurrentTranslations());
currentDropDownMenu.set({ left, top, items });
}
async function handleOpenCloudLogin() {