From c0c4730bad878e8958181af087650838d1463bea Mon Sep 17 00:00:00 2001 From: Vangelis Date: Wed, 8 Nov 2017 00:14:20 +0100 Subject: [PATCH] Added top level menu shortcuts, pull labels from messages.json (#1702) * Added top level menu shortcuts (Fixes #1688 and #1695). The ampersand (&) character in front of a letter in a menu label indicates that the letter that follows '&' will be used as a keyboard shortcut letter to access this menu. In Windows/Linux, the default shortcut combination is Alt+. * Use non-hardcoded menu labels. The menu labels were hardcoded in English. We should not be using plain strings right in the source code, but pulling them from the `messages.json` files instead. --- _locales/en/messages.json | 20 ++++++++++++++++++++ app/menu.js | 8 +++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 62af2240e..39b984804 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1,4 +1,24 @@ { + "mainMenuFile": { + "message": "&File", + "description": "The label that is used for the File menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt- combination." + }, + "mainMenuEdit": { + "message": "&Edit", + "description": "The label that is used for the Edit menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt- combination." + }, + "mainMenuView": { + "message": "&View", + "description": "The label that is used for the View menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt- combination." + }, + "mainMenuWindow": { + "message": "&Window", + "description": "The label that is used for the Window menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt- combination." + }, + "mainMenuHelp": { + "message": "&Help", + "description": "The label that is used for the Help menu in the program main menu. The '&' indicates that the following letter will be used as the keyboard 'shortcut letter' for accessing the menu with the Alt- combination." + }, "loading": { "message": "Loading...", "description": "Message shown on the loading screen before we've loaded any messages" diff --git a/app/menu.js b/app/menu.js index 9c29c44b5..4eacc20ef 100644 --- a/app/menu.js +++ b/app/menu.js @@ -7,7 +7,7 @@ function createTemplate(options, messages) { const openForums = options.openForums; let template = [{ - label: 'File', + label: messages.mainMenuFile.message, submenu: [ { role: 'quit', @@ -15,7 +15,7 @@ function createTemplate(options, messages) { ] }, { - label: 'Edit', + label: messages.mainMenuEdit.message, submenu: [ { role: 'undo', @@ -47,7 +47,7 @@ function createTemplate(options, messages) { ] }, { - label: 'View', + label: messages.mainMenuView.message, submenu: [ { role: 'resetzoom', @@ -80,6 +80,7 @@ function createTemplate(options, messages) { ] }, { + label: messages.mainMenuWindow.message, role: 'window', submenu: [ { @@ -88,6 +89,7 @@ function createTemplate(options, messages) { ] }, { + label: messages.mainMenuHelp.message, role: 'help', submenu: [ {