mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 11:53:44 +08:00
UX: Show translated modifier keys in editor shortcuts
This commit is contained in:
parent
5234e54f7e
commit
a00c373b6f
|
@ -119,16 +119,24 @@ Toolbar.prototype.addButton = function(button) {
|
||||||
if (button.shortcut) {
|
if (button.shortcut) {
|
||||||
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
||||||
const mod = mac ? 'Meta' : 'Ctrl';
|
const mod = mac ? 'Meta' : 'Ctrl';
|
||||||
createdButton.title = `${title} (${mod}+${button.shortcut})`;
|
var shortcutTitle = `${mod}+${button.shortcut}`;
|
||||||
|
|
||||||
// Mac users are used to glyphs for shortcut keys
|
// Mac users are used to glyphs for shortcut keys
|
||||||
if (mac) {
|
if (mac) {
|
||||||
createdButton.title = createdButton.title.replace('Shift', "\u21E7")
|
shortcutTitle = shortcutTitle
|
||||||
.replace('Meta', "\u2318")
|
.replace('Shift', "\u21E7")
|
||||||
.replace('Alt', "\u2325")
|
.replace('Meta', "\u2318")
|
||||||
.replace(/\+/g, '');
|
.replace('Alt', "\u2325")
|
||||||
|
.replace(/\+/g, '');
|
||||||
|
} else {
|
||||||
|
shortcutTitle = shortcutTitle
|
||||||
|
.replace('Shift', I18n.t('shortcut_modifier_key.shift'))
|
||||||
|
.replace('Ctrl', I18n.t('shortcut_modifier_key.ctrl'))
|
||||||
|
.replace('Alt', I18n.t('shortcut_modifier_key.alt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createdButton.title = `${title} (${shortcutTitle})`;
|
||||||
|
|
||||||
this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton;
|
this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton;
|
||||||
} else {
|
} else {
|
||||||
createdButton.title = title;
|
createdButton.title = title;
|
||||||
|
|
|
@ -829,6 +829,11 @@ en:
|
||||||
twitter: "Twitter"
|
twitter: "Twitter"
|
||||||
emoji_one: "Emoji One"
|
emoji_one: "Emoji One"
|
||||||
|
|
||||||
|
shortcut_modifier_key:
|
||||||
|
shift: 'Shift'
|
||||||
|
ctrl: 'Ctrl'
|
||||||
|
alt: 'Alt'
|
||||||
|
|
||||||
composer:
|
composer:
|
||||||
emoji: "Emoji :smile:"
|
emoji: "Emoji :smile:"
|
||||||
more_emoji: "more..."
|
more_emoji: "more..."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user