From 2294936595355703afba14a91adb73c321abf8ac Mon Sep 17 00:00:00 2001 From: Yusuke Nemoto Date: Wed, 28 Dec 2016 22:46:11 +0900 Subject: PLT-4648 break `/shortcuts` block (#4829) --- api/command_shortcuts.go | 56 ++++++++++++++++---- i18n/en.json | 132 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 162 insertions(+), 26 deletions(-) diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go index f75b419b1..1664221c1 100644 --- a/api/command_shortcuts.go +++ b/api/command_shortcuts.go @@ -36,23 +36,59 @@ func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { } func (me *ShortcutsProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { - shortcutIds := [4]string{ - "api.command_shortcuts.nav", - "api.command_shortcuts.files", - "api.command_shortcuts.msgs", - "api.command_shortcuts.browser", + shortcutIds := [28]string{ + "api.command_shortcuts.header", + // Nav shortcuts + "api.command_shortcuts.nav.header", + "api.command_shortcuts.nav.prev", + "api.command_shortcuts.nav.next", + "api.command_shortcuts.nav.unread_prev", + "api.command_shortcuts.nav.unread_next", + "api.command_shortcuts.nav.switcher", + "api.command_shortcuts.nav.settings", + "api.command_shortcuts.nav.recent_mentions", + // Files shortcuts + "api.command_shortcuts.files.header", + "api.command_shortcuts.files.upload", + // Msg shortcuts + "api.command_shortcuts.msgs.header", + "api.command_shortcuts.msgs.mark_as_read", + "api.command_shortcuts.msgs.reprint_prev", + "api.command_shortcuts.msgs.reprint_next", + "api.command_shortcuts.msgs.edit", + "api.command_shortcuts.msgs.comp_username", + "api.command_shortcuts.msgs.comp_channel", + "api.command_shortcuts.msgs.comp_emoji", + // Browser shortcuts + "api.command_shortcuts.browser.header", + "api.command_shortcuts.browser.channel_prev", + "api.command_shortcuts.browser.channel_next", + "api.command_shortcuts.browser.font_increase", + "api.command_shortcuts.browser.font_decrease", + "api.command_shortcuts.browser.highlight_prev", + "api.command_shortcuts.browser.highlight_next", + "api.command_shortcuts.browser.newline", } - var buffer bytes.Buffer + var osDependentWords map[string]interface{} if strings.Contains(message, "mac") { - for _, element := range shortcutIds { - buffer.WriteString(c.T(element + "_mac")) + osDependentWords = map[string]interface{}{ + "CmdOrCtrl": c.T("api.command_shortcuts.cmd"), + "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd_mac"), + "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd_mac"), } } else { - for _, element := range shortcutIds { - buffer.WriteString(c.T(element)) + osDependentWords = map[string]interface{}{ + "CmdOrCtrl": c.T("api.command_shortcuts.ctrl"), + "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd"), + "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd"), } } + var buffer bytes.Buffer + for _, element := range shortcutIds { + buffer.WriteString(c.T(element, osDependentWords)) + } + return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: buffer.String()} } diff --git a/i18n/en.json b/i18n/en.json index 51f296dc5..e5bee2806 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -644,44 +644,144 @@ "translation": "You are now online" }, { - "id": "api.command_shortcuts.browser", - "translation": "#### Built-in Browser Commands\n\nALT+LEFT: Previous channel in your history\nALT+RIGHT: Next channel in your history\nCTRL+PLUS: Increase font size (zoom in)\nCTRL+MINUS: Decrease font size (zoom out)\nSHIFT+UP (in input field): Highlight text to the previous line\nSHIFT+DOWN (in input field): Highlight text to the next line\nSHIFT+ENTER (in input field): Create a new line\n" + "id": "api.command_shortcuts.browser.channel_prev", + "translation": "{{.ChannelPrevCmd}}: Previous channel in your history\n" }, { - "id": "api.command_shortcuts.browser_mac", - "translation": "#### Built-in Browser Commands\n\nCMD+[: Previous channel in your history\nCMD+]: Next channel in your history\nCMD+PLUS: Increase font size (zoom in)\nCMD+MINUS: Decrease font size (zoom out)\nSHIFT+UP (in input field): Highlight text to the previous line\nSHIFT+DOWN (in input field): Highlight text to the next line\nSHIFT+ENTER (in input field): Create a new line\n" + "id": "api.command_shortcuts.browser.channel_prev.cmd", + "translation": "ALT+LEFT" + }, + { + "id": "api.command_shortcuts.browser.channel_prev.cmd_mac", + "translation": "CMD+[" + }, + { + "id": "api.command_shortcuts.browser.channel_next", + "translation": "{{.ChannelNextCmd}}: Next channel in your history\n" + }, + { + "id": "api.command_shortcuts.browser.channel_next.cmd", + "translation": "ALT+RIGHT" + }, + { + "id": "api.command_shortcuts.browser.channel_next.cmd_mac", + "translation": "CMD+]" + }, + { + "id": "api.command_shortcuts.browser.font_increase", + "translation": "{{.CmdOrCtrl}}+PLUS: Increase font size (zoom in)\n" + }, + { + "id": "api.command_shortcuts.browser.font_decrease", + "translation": "{{.CmdOrCtrl}}+MINUS: Decrease font size (zoom out)\n" + }, + { + "id": "api.command_shortcuts.browser.header", + "translation": "#### Built-in Browser Commands\n\n" + }, + { + "id": "api.command_shortcuts.browser.highlight_prev", + "translation": "SHIFT+UP (in input field): Highlight text to the previous line\n" + }, + { + "id": "api.command_shortcuts.browser.highlight_next", + "translation": "SHIFT+DOWN (in input field): Highlight text to the next line\n" + }, + { + "id": "api.command_shortcuts.browser.newline", + "translation": "SHIFT+ENTER (in input field): Create a new line\n" + }, + { + "id": "api.command_shortcuts.cmd", + "translation": "CMD" + }, + { + "id": "api.command_shortcuts.ctrl", + "translation": "CTRL" }, { "id": "api.command_shortcuts.desc", "translation": "Displays a list of keyboard shortcuts" }, { - "id": "api.command_shortcuts.files", - "translation": "#### Files\n\nCTRL+U: Upload file(s)\n\n" + "id": "api.command_shortcuts.files.header", + "translation": "#### Files\n\n" + }, + { + "id": "api.command_shortcuts.files.upload", + "translation": "{{.CmdOrCtrl}}+U: Upload file(s)\n\n" + }, + { + "id": "api.command_shortcuts.header", + "translation": "### Keyboard Shortcuts\n\n" + }, + { + "id": "api.command_shortcuts.msgs.comp_channel", + "translation": "~[character]+TAB: Autocomplete channel beginning with [character]\n" + }, + { + "id": "api.command_shortcuts.msgs.comp_emoji", + "translation": ":[character]+TAB: Autocomplete emoji beginning with [character]\n\n" + }, + { + "id": "api.command_shortcuts.msgs.comp_username", + "translation": "@[character]+TAB: Autocomplete @username beginning with [character]\n" + }, + { + "id": "api.command_shortcuts.msgs.edit", + "translation": "UP (in empty input field): Edit your last message in the current channel\n" + }, + { + "id": "api.command_shortcuts.msgs.header", + "translation": "#### Messages\n\n" }, { - "id": "api.command_shortcuts.files_mac", - "translation": "#### Files\n\nCMD+U: Upload file(s)\n\n" + "id": "api.command_shortcuts.msgs.mark_as_read", + "translation": "ESC: Mark all messages in the current channel as read\n" }, { - "id": "api.command_shortcuts.msgs", - "translation": "#### Messages\n\nESC: Mark all messages in the current channel as read\nCTRL+UP (in empty input field): Reprint the previous message or slash command you entered\nCTRL+DOWN (in empty input field): Reprint the next message or slash command you entered\nUP (in empty input field): Edit your last message in the current channel\n@[character]+TAB: Autocomplete @username beginning with [character]\n~[character]+TAB: Autocomplete channel beginning with [character]\n:[character]+TAB: Autocomplete emoji beginning with [character]\n\n" + "id": "api.command_shortcuts.msgs.reprint_prev", + "translation": "{{.CmdOrCtrl}}+UP (in empty input field): Reprint the previous message or slash command you entered\n" }, { - "id": "api.command_shortcuts.msgs_mac", - "translation": "#### Messages\n\nESC: Mark all messages in the current channel as read\nCMD+UP (in empty input field): Reprint the previous message or slash command you entered\nCMD+DOWN (in empty input field): Reprint the next message or slash command you entered\nUP (in empty input field): Edit your last message in the current channel\n@[character]+TAB: Autocomplete @username beginning with [character]\n~[character]+TAB: Autocomplete channel beginning with [character]\n:[character]+TAB: Autocomplete emoji beginning with [character]\n\n" + "id": "api.command_shortcuts.msgs.reprint_next", + "translation": "{{.CmdOrCtrl}}+DOWN (in empty input field): Reprint the next message or slash command you entered\n" }, { "id": "api.command_shortcuts.name", "translation": "shortcuts" }, { - "id": "api.command_shortcuts.nav", - "translation": "### Keyboard Shortcuts\n\n#### Navigation\n\nALT+UP: Previous channel or direct message in left hand sidebar\nALT+DOWN: Next channel or direct message in left hand sidebar\nALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\nALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\nCTRL+K: Open a quick channel switcher dialog\nCTRL+SHIFT+A: Open account settings\nCTRL+SHIFT+M: Open recent mentions\n\n" + "id": "api.command_shortcuts.nav.header", + "translation": "#### Navigation\n\n" + }, + { + "id": "api.command_shortcuts.nav.next", + "translation": "ALT+DOWN: Next channel or direct message in left hand sidebar\n" + }, + { + "id": "api.command_shortcuts.nav.prev", + "translation": "ALT+UP: Previous channel or direct message in left hand sidebar\n" + }, + { + "id": "api.command_shortcuts.nav.recent_mentions", + "translation": "{{.CmdOrCtrl}}+SHIFT+M: Open recent mentions\n\n" + }, + { + "id": "api.command_shortcuts.nav.settings", + "translation": "{{.CmdOrCtrl}}+SHIFT+A: Open account settings\n" + }, + { + "id": "api.command_shortcuts.nav.switcher", + "translation": "{{.CmdOrCtrl}}+K: Open a quick channel switcher dialog\n" + }, + { + "id": "api.command_shortcuts.nav.unread_prev", + "translation": "ALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\n" }, { - "id": "api.command_shortcuts.nav_mac", - "translation": "### Keyboard Shortcuts\n\n#### Navigation\n\nALT+UP: Previous channel or direct message in left hand sidebar\nALT+DOWN: Next channel or direct message in left hand sidebar\nALT+SHIFT+UP: Previous channel or direct message in left hand sidebar with unread messages\nALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\nCMD+K: Open a quick channel switcher dialog\nCMD+SHIFT+A: Open account settings\nCMD+SHIFT+M: Open recent mentions\n\n" + "id": "api.command_shortcuts.nav.unread_next", + "translation": "ALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\n" }, { "id": "api.command_shrug.desc", -- cgit v1.2.3-1-g7c22