PLT-4648 break /shortcuts block (#4829)

This commit is contained in:
Yusuke Nemoto
2016-12-28 22:46:11 +09:00
committed by enahum
parent 5fd11bd674
commit 2294936595
2 changed files with 165 additions and 29 deletions

View File

@@ -36,22 +36,58 @@ 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 osDependentWords map[string]interface{}
if strings.Contains(message, "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 {
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
if strings.Contains(message, "mac") {
for _, element := range shortcutIds {
buffer.WriteString(c.T(element + "_mac"))
}
} else {
for _, element := range shortcutIds {
buffer.WriteString(c.T(element))
}
for _, element := range shortcutIds {
buffer.WriteString(c.T(element, osDependentWords))
}
return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: buffer.String()}

View File

@@ -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_mac",
"translation": "#### Files\n\nCMD+U: Upload file(s)\n\n"
"id": "api.command_shortcuts.files.upload",
"translation": "{{.CmdOrCtrl}}+U: Upload file(s)\n\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.header",
"translation": "### Keyboard Shortcuts\n\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.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.msgs.mark_as_read",
"translation": "ESC: Mark all messages in the current channel as read\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.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_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.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.unread_next",
"translation": "ALT+SHIFT+DOWN: Next channel or direct message in left hand sidebar with unread messages\n"
},
{
"id": "api.command_shrug.desc",