i18n hardcoded strings from boardPage's UndoRedoHotKeys.tsx (#3483)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
hyugabokko 2022-08-04 07:30:28 +09:00 committed by GitHub
parent 1e1854a5dd
commit 6350263f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View File

@ -250,6 +250,12 @@
"URLProperty.copiedLink": "Copied!",
"URLProperty.copy": "Copy",
"URLProperty.edit": "Edit",
"UndoRedoHotKeys.canRedo": "Redo",
"UndoRedoHotKeys.canRedo-with-description": "Redo {description}",
"UndoRedoHotKeys.canUndo": "Undo",
"UndoRedoHotKeys.canUndo-with-description": "Undo {description}",
"UndoRedoHotKeys.cannotRedo": "Nothing to Redo",
"UndoRedoHotKeys.cannotUndo": "Nothing to Undo",
"ValueSelector.noOptions": "No options. Start typing to add the first one!",
"ValueSelector.valueSelector": "Value selector",
"ValueSelectorLabel.openMenu": "Open menu",

View File

@ -1,25 +1,36 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {useHotkeys} from 'react-hotkeys-hook'
import {useIntl} from 'react-intl'
import {sendFlashMessage} from '../../components/flashMessages'
import mutator from '../../mutator'
import {Utils} from '../../utils'
const UndoRedoHotKeys = (): null => {
const intl = useIntl()
useHotkeys('ctrl+z,cmd+z', () => {
Utils.log('Undo')
if (mutator.canUndo) {
const description = mutator.undoDescription
mutator.undo().then(() => {
if (description) {
sendFlashMessage({content: `Undo ${description}`, severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.canUndo-with-description', defaultMessage: 'Undo {description}'}, {description: description}),
severity: 'low'
})
} else {
sendFlashMessage({content: 'Undo', severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.canUndo', defaultMessage: 'Undo'}),
severity: 'low'})
}
})
} else {
sendFlashMessage({content: 'Nothing to Undo', severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.cannotUndo', defaultMessage: 'Nothing to Undo'}),
severity: 'low'
})
}
})
@ -29,13 +40,22 @@ const UndoRedoHotKeys = (): null => {
const description = mutator.redoDescription
mutator.redo().then(() => {
if (description) {
sendFlashMessage({content: `Redo ${description}`, severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.canRedo-with-description', defaultMessage: 'Redo {description}'}, {description: description}),
severity: 'low'
})
} else {
sendFlashMessage({content: 'Redu', severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.canRedo', defaultMessage: 'Redo'}),
severity: 'low'
})
}
})
} else {
sendFlashMessage({content: 'Nothing to Redo', severity: 'low'})
sendFlashMessage({
content: intl.formatMessage({id: 'UndoRedoHotKeys.cannotRedo', defaultMessage: 'Nothing to Redo'}),
severity: 'low'
})
}
})
return null