fix: i18n for default menu

This commit is contained in:
JellyBrick
2023-12-02 03:49:25 +09:00
parent 5f642007ba
commit b92205a228
3 changed files with 58 additions and 14 deletions

View File

@ -542,7 +542,15 @@
} }
}, },
"view": { "view": {
"label": "View" "label": "View",
"submenu": {
"reload": "Reload",
"force-reload": "Force Reload",
"toggle-fullscreen": "Toggle Full Screen",
"reset-zoom": "Actual Size",
"zoom-in": "Zoom In",
"zoom-out": "Zoom Out"
}
}, },
"navigation": { "navigation": {
"label": "Navigation", "label": "Navigation",
@ -550,10 +558,19 @@
"go-back": "Go back", "go-back": "Go back",
"go-forward": "Go forward", "go-forward": "Go forward",
"copy-current-url": "Copy current URL", "copy-current-url": "Copy current URL",
"restart": "Restart App" "restart": "Restart App",
"quit": "Exit2"
} }
}, },
"about": "About" "about": "About"
},
"tray": {
"play-pause": "Play/Pause",
"next": "Next",
"previous": "Previous",
"show": "Show",
"restart": "Restart App",
"quit": "Quit"
} }
}, },
"common": { "common": {

View File

@ -1,3 +1,5 @@
import process from 'node:process';
import is from 'electron-is'; import is from 'electron-is';
import { import {
app, app,
@ -410,7 +412,10 @@ export const mainMenuTemplate = async (
} }
}, },
} }
: { role: 'toggleDevTools' }, : {
label: t('main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools'),
role: 'toggleDevTools'
},
{ {
label: t('main.menu.options.submenu.advanced-options.submenu.edit-config-json'), label: t('main.menu.options.submenu.advanced-options.submenu.edit-config-json'),
click() { click() {
@ -424,20 +429,34 @@ export const mainMenuTemplate = async (
{ {
label: t('main.menu.view.label'), label: t('main.menu.view.label'),
submenu: [ submenu: [
{ role: 'reload' }, {
{ role: 'forceReload' }, label: t('main.menu.view.submenu.reload'),
role: 'reload',
},
{
label: t('main.menu.view.submenu.force-reload'),
role: 'forceReload',
},
{ type: 'separator' }, { type: 'separator' },
{ {
label: t('main.menu.view.submenu.zoom-in'),
role: 'zoomIn', role: 'zoomIn',
accelerator: process.platform === 'darwin' ? 'Cmd+I' : 'Ctrl+I', accelerator: process.platform === 'darwin' ? 'Cmd+I' : 'Ctrl+I',
}, },
{ {
label: t('main.menu.view.submenu.zoom-out'),
role: 'zoomOut', role: 'zoomOut',
accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+O', accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+O',
}, },
{ role: 'resetZoom' }, {
label: t('main.menu.view.submenu.reset-zoom'),
role: 'resetZoom',
},
{ type: 'separator' }, { type: 'separator' },
{ role: 'togglefullscreen' }, {
label: t('main.menu.view.submenu.toggle-fullscreen'),
role: 'togglefullscreen',
},
], ],
}, },
{ {
@ -470,7 +489,10 @@ export const mainMenuTemplate = async (
label: t('main.menu.navigation.submenu.restart'), label: t('main.menu.navigation.submenu.restart'),
click: restart, click: restart,
}, },
{ role: 'quit' }, {
label: t('main.menu.navigation.submenu.quit'),
role: 'quit',
},
], ],
}, },
{ {

View File

@ -7,6 +7,8 @@ import config from './config';
import { restart } from './providers/app-controls'; import { restart } from './providers/app-controls';
import getSongControls from './providers/song-controls'; import getSongControls from './providers/song-controls';
import { t } from '@/i18n';
import type { MenuTemplate } from './menu'; import type { MenuTemplate } from './menu';
// Prevent tray being garbage collected // Prevent tray being garbage collected
@ -70,35 +72,38 @@ export const setUpTray = (app: Electron.App, win: Electron.BrowserWindow) => {
const template: MenuTemplate = [ const template: MenuTemplate = [
{ {
label: 'Play/Pause', label: t('main.tray.play-pause'),
click() { click() {
playPause(); playPause();
}, },
}, },
{ {
label: 'Next', label: t('main.tray.next'),
click() { click() {
next(); next();
}, },
}, },
{ {
label: 'Previous', label: t('main.tray.previous'),
click() { click() {
previous(); previous();
}, },
}, },
{ {
label: 'Show', label: t('main.tray.show'),
click() { click() {
win.show(); win.show();
app.dock?.show(); app.dock?.show();
}, },
}, },
{ {
label: 'Restart App', label: t('main.tray.restart'),
click: restart, click: restart,
}, },
{ role: 'quit' }, {
label: t('main.tray.quit'),
role: 'quit',
},
]; ];
const trayMenu = Menu.buildFromTemplate(template); const trayMenu = Menu.buildFromTemplate(template);