Now works with other languages pending MacOS Strings deletes

This commit is contained in:
Mefsaal 2022-04-30 23:22:15 -03:00
parent 54eb414285
commit 0baafbf447

View file

@ -3,7 +3,7 @@ import {utils} from "../base/utils";
export default class Thumbar { export default class Thumbar {
private i18n: any = undefined;
/** /**
* Base Plugin Details (Eventually implemented into a GUI in settings) * Base Plugin Details (Eventually implemented into a GUI in settings)
*/ */
@ -17,173 +17,173 @@ export default class Thumbar {
* Menubar Assets * Menubar Assets
* @private * @private
*/ */
private isMac: boolean = process.platform === 'darwin'; private isMac: boolean = process.platform === 'darwin';
private _menuTemplate: any = [ private _menuTemplate: any = [
{ {
label: app.getName(), label: app.getName(),
submenu: [ submenu: [
{ {
label: utils.getLocale('About', 'menubar.options.about'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.about'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('about')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('about')`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Settings', 'menubar.options.settings'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.settings'),
accelerator: utils.getStoreValue("general.keybindings.settings").join('+'), accelerator: utils.getStoreValue("general.keybindings.settings").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('settings')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('settings')`)
}, },
{type: 'separator'}, {type: 'separator'},
{role: 'services', label: utils.getLocale('services', 'menubar.options.services')}, {role: 'services', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.services')},
{type: 'separator'}, {type: 'separator'},
{role: 'hide', label: utils.getLocale('hide', 'menubar.options.hide')}, {role: 'hide', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.hide')},
{role: 'hideOthers', label: utils.getLocale('hideOthers', 'menubar.options.hideothers')}, {role: 'hideOthers', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.hideothers')},
{role: 'unhide', label: utils.getLocale('unhide', 'menubar.options.unhide')}, {role: 'unhide', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.unhide')},
{type: 'separator'}, {type: 'separator'},
{role: 'quit', label: utils.getLocale('quit', 'menubar.options.quit')} {role: 'quit', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.quit')}
] ]
}, },
{ {
label: utils.getLocale('View', 'menubar.options.view'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.view'),
submenu: [ submenu: [
{role: 'reload', label: utils.getLocale('reload', 'menubar.options.reloads')}, {role: 'reload', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.reloads')},
{role: 'forceReload', label: utils.getLocale('forceReload', 'menubar.options.forcereload')}, {role: 'forceReload', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.forcereload')},
{role: 'toggleDevTools', label: utils.getLocale('toggleDevTools', 'menubar.options.toggledevtools')}, {role: 'toggleDevTools', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.toggledevtools')},
{type: 'separator'}, {type: 'separator'},
{role: 'resetZoom', label: utils.getLocale('resetZoom', 'menubar.options.resetzoom')}, {role: 'resetZoom', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.resetzoom')},
{role: 'zoomIn', label: utils.getLocale('zoomIn', 'menubar.options.zoomin')}, {role: 'zoomIn', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.zoomin')},
{role: 'zoomOut', label: utils.getLocale('zoomOut', 'menubar.options.zoomout')}, {role: 'zoomOut', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.zoomout')},
{type: 'separator'}, {type: 'separator'},
{role: 'togglefullscreen', label: utils.getLocale('togglefullscreen', 'menubar.options.togglefullscreen')}, {role: 'togglefullscreen', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.togglefullscreen')},
] ]
}, },
{ {
label: utils.getLocale('Window', 'menubar.options.window'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.window'),
submenu: [ submenu: [
{role: 'minimize', label: utils.getLocale('minimize', 'menubar.options.minimize')}, {role: 'minimize', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.minimize')},
{ {
label: utils.getLocale('Show', 'menubar.options.show'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.show'),
click: () => utils.getWindow().show() click: () => utils.getWindow().show()
}, },
{role: 'zoom', label: utils.getLocale('zoom', 'menubar.options.zoom')}, {role: 'zoom', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.zoom')},
...(this.isMac ? [ ...(this.isMac ? [
{type: 'separator'}, {type: 'separator'},
{role: 'front', label: utils.getLocale('front', 'menubar.options.front')}, {role: 'front', label: utils.getLocale('front', 'menubar.options.front')},
{role: 'close', label: utils.getLocale('close', 'menubar.options.close')}, {role: 'close', label: utils.getLocale('close', 'menubar.options.close')},
] : [ ] : [
{role: 'close', label: utils.getLocale('close', 'menubar.options.close')}, {role: 'close', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.close')},
]), ]),
{ {
label: utils.getLocale('Edit', 'menubar.options.edit'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.edit'),
submenu: [ submenu: [
{role: 'undo', label: utils.getLocale('undo', 'menubar.options.undo')}, {role: 'undo', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.undo')},
{role: 'redo', label: utils.getLocale('redo', 'menubar.options.redo')}, {role: 'redo', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.redo')},
{type: 'separator'}, {type: 'separator'},
{role: 'cut', label: utils.getLocale('cut', 'menubar.options.cut')}, {role: 'cut', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.cut')},
{role: 'copy', label: utils.getLocale('copy', 'menubar.options.copy')}, {role: 'copy', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.copy')},
{role: 'paste', label: utils.getLocale('paste', 'menubar.options.paste')}, {role: 'paste', label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.paste')},
] ]
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Toggle Private Session', 'menubar.options.toggleprivate'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.toggleprivate'),
accelerator: utils.getStoreValue("general.keybindings.togglePrivateSession").join('+'), accelerator: utils.getStoreValue("general.keybindings.togglePrivateSession").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.cfg.general.privateEnabled = !app.cfg.general.privateEnabled`) click: () => utils.getWindow().webContents.executeJavaScript(`app.cfg.general.privateEnabled = !app.cfg.general.privateEnabled`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Web Remote', 'menubar.options.webremote'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.webremote'),
accelerator: utils.getStoreValue("general.keybindings.webRemote").join('+'), accelerator: utils.getStoreValue("general.keybindings.webRemote").join('+'),
sublabel: 'Opens in external window', sublabel: 'Opens in external window',
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('remote-pair')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('remote-pair')`)
}, },
{ {
label: utils.getLocale('Audio Settings', 'menubar.options.audio'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.audio'),
accelerator: utils.getStoreValue("general.keybindings.audioSettings").join('+'), accelerator: utils.getStoreValue("general.keybindings.audioSettings").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.audioSettings = true`) click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.audioSettings = true`)
}, },
{ {
label: utils.getLocale('Plug-in Menu', 'menubar.options.plugins'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.plugins'),
accelerator: utils.getStoreValue("general.keybindings.pluginMenu").join('+'), accelerator: utils.getStoreValue("general.keybindings.pluginMenu").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.pluginMenu = true`) click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.pluginMenu = true`)
} }
] ]
}, },
{ {
label: utils.getLocale('Controls', 'menubar.options.controls'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.controls'),
submenu: [ submenu: [
{ {
label: utils.getLocale('Pause / Play', 'menubar.options.playpause'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.playpause'),
accelerator: 'Space', accelerator: 'Space',
click: () => utils.getWindow().webContents.executeJavaScript(`app.SpacePause()`) click: () => utils.getWindow().webContents.executeJavaScript(`app.SpacePause()`)
}, },
{ {
label: utils.getLocale('Next', 'menubar.options.next'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.next'),
accelerator: 'CommandOrControl+Right', accelerator: 'CommandOrControl+Right',
click: () => utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.next()`) click: () => utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.next()`)
}, },
{ {
label: utils.getLocale('Previous', 'menubar.options.previous'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.previous'),
accelerator: 'CommandOrControl+Left', accelerator: 'CommandOrControl+Left',
click: () => utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.previous()`) click: () => utils.getWindow().webContents.executeJavaScript(`MusicKitInterop.previous()`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Volume Up', 'menubar.options.volumeup'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.volumeup'),
accelerator: 'CommandOrControl+Up', accelerator: 'CommandOrControl+Up',
click: () => utils.getWindow().webContents.executeJavaScript(`app.volumeUp()`) click: () => utils.getWindow().webContents.executeJavaScript(`app.volumeUp()`)
}, },
{ {
label: utils.getLocale('Volume Down', 'menubar.options.volumedown'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.volumedown'),
accelerator: 'CommandOrControl+Down', accelerator: 'CommandOrControl+Down',
click: () => utils.getWindow().webContents.executeJavaScript(`app.volumeDown()`) click: () => utils.getWindow().webContents.executeJavaScript(`app.volumeDown()`)
}, },
{ {
label: utils.getLocale('Browse', 'menubar.options.browse'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.browse'),
accelerator: utils.getStoreValue("general.keybindings.browse").join('+'), accelerator: utils.getStoreValue("general.keybindings.browse").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('browse')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('browse')`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Artists', 'menubar.options.artists'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.artists'),
accelerator: utils.getStoreValue("general.keybindings.artists").join('+'), accelerator: utils.getStoreValue("general.keybindings.artists").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('library-artists')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('library-artists')`)
}, },
{ {
label: utils.getLocale('Search', 'menubar.options.search'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.search'),
accelerator: utils.getStoreValue("general.keybindings.search").join('+'), accelerator: utils.getStoreValue("general.keybindings.search").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('search')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('search')`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Album', 'menubar.options.albums'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.albums'),
accelerator: utils.getStoreValue("general.keybindings.albums").join('+'), accelerator: utils.getStoreValue("general.keybindings.albums").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('library-albums')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('library-albums')`)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Cast To Devices', 'menubar.options.cast'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.cast'),
accelerator: utils.getStoreValue("general.keybindings.castToDevices").join('+'), accelerator: utils.getStoreValue("general.keybindings.castToDevices").join('+'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.castMenu = true`) click: () => utils.getWindow().webContents.executeJavaScript(`app.modals.castMenu = true`)
} }
] ]
}, },
{ {
label: utils.getLocale('Account', 'menubar.options.account'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.account'),
submenu: [ submenu: [
{ {
label: utils.getLocale('Account Settings', 'menubar.options.accountsettings'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.accountsettings'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('apple-account-settings')`) click: () => utils.getWindow().webContents.executeJavaScript(`app.appRoute('apple-account-settings')`)
}, },
{ {
label: utils.getLocale('Sign Out', 'menubar.options.signout'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.signout'),
click: () => utils.getWindow().webContents.executeJavaScript(`app.unauthorize()`) click: () => utils.getWindow().webContents.executeJavaScript(`app.unauthorize()`)
} }
] ]
}, },
{ {
label: utils.getLocale('Support', 'menubar.options.support'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.support'),
role: utils.getLocale('help', 'menubar.options.help'), role: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.help'),
submenu: [ submenu: [
{ {
label: utils.getLocale('Discord', 'menubar.options.discord'), label: utils.getLocale('Discord', 'menubar.options.discord'),
@ -195,35 +195,35 @@ export default class Thumbar {
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Report a...', 'menubar.options.report'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.report'),
submenu: [ submenu: [
{ {
label: utils.getLocale('Bug', 'menubar.options.bug'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.bug'),
click: () => shell.openExternal("https://github.com/ciderapp/Cider/issues/new?assignees=&labels=bug%2Ctriage&template=bug_report.yaml&title=%5BBug%5D%3A+").catch(console.error) click: () => shell.openExternal("https://github.com/ciderapp/Cider/issues/new?assignees=&labels=bug%2Ctriage&template=bug_report.yaml&title=%5BBug%5D%3A+").catch(console.error)
}, },
{ {
label: utils.getLocale('Feature Request', 'menubar.options.feature'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.feature'),
click: () => shell.openExternal("https://github.com/ciderapp/Cider/discussions/new?category=feature-request").catch(console.error) click: () => shell.openExternal("https://github.com/ciderapp/Cider/discussions/new?category=feature-request").catch(console.error)
}, },
{ {
label: utils.getLocale('Translation Report/Request', 'menubar.options.trans'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.trans'),
click: () => shell.openExternal("https://github.com/ciderapp/Cider/issues/new?assignees=&labels=%F0%9F%8C%90+Translations&template=translation.yaml&title=%5BTranslation%5D%3A+").catch(console.error) click: () => shell.openExternal("https://github.com/ciderapp/Cider/issues/new?assignees=&labels=%F0%9F%8C%90+Translations&template=translation.yaml&title=%5BTranslation%5D%3A+").catch(console.error)
}, },
] ]
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('View License', 'menubar.options.license'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.license'),
click: () => shell.openExternal("https://github.com/ciderapp/Cider/blob/main/LICENSE").catch(console.error) click: () => shell.openExternal("https://github.com/ciderapp/Cider/blob/main/LICENSE").catch(console.error)
}, },
{type: 'separator'}, {type: 'separator'},
{ {
label: utils.getLocale('Toggle Developer Tools', 'menubar.options.toggledevtools'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.toggledevtools'),
accelerator: utils.getStoreValue("general.keybindings.openDeveloperTools").join('+'), accelerator: utils.getStoreValue("general.keybindings.openDeveloperTools").join('+'),
click: () => utils.getWindow().webContents.openDevTools() click: () => utils.getWindow().webContents.openDevTools()
}, },
{ {
label: utils.getLocale('Open Configuration File in Editor', 'menubar.options.conf'), label: utils.getLocale(utils.getStoreValue('general.language'), 'menubar.options.conf'),
click: () => utils.getStoreInstance().openInEditor() click: () => utils.getStoreInstance().openInEditor()
} }
] ]