mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-15 05:50:24 +00:00
Translate del in shortcut dialog (#26865)
This commit is contained in:
@@ -11,20 +11,22 @@ import type { HomeAssistant } from "../../types";
|
|||||||
import { isMac } from "../../util/is_mac";
|
import { isMac } from "../../util/is_mac";
|
||||||
|
|
||||||
interface Text {
|
interface Text {
|
||||||
type: "text";
|
textTranslationKey: LocalizeKeys;
|
||||||
key: LocalizeKeys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShortcutString = string | { key: LocalizeKeys };
|
interface LocalizedShortcut {
|
||||||
|
shortcutTranslationKey: LocalizeKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShortcutString = string | LocalizedShortcut;
|
||||||
|
|
||||||
interface Shortcut {
|
interface Shortcut {
|
||||||
type: "shortcut";
|
|
||||||
shortcut: ShortcutString[];
|
shortcut: ShortcutString[];
|
||||||
key: LocalizeKeys;
|
descriptionTranslationKey: LocalizeKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Section {
|
interface Section {
|
||||||
key: LocalizeKeys;
|
titleTranslationKey: LocalizeKeys;
|
||||||
items: (Text | Shortcut)[];
|
items: (Text | Shortcut)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,105 +34,115 @@ const CTRL_CMD = "__CTRL_CMD__";
|
|||||||
|
|
||||||
const _SHORTCUTS: Section[] = [
|
const _SHORTCUTS: Section[] = [
|
||||||
{
|
{
|
||||||
key: "ui.dialogs.shortcuts.searching.title",
|
titleTranslationKey: "ui.dialogs.shortcuts.searching.title",
|
||||||
items: [
|
items: [
|
||||||
{ type: "text", key: "ui.dialogs.shortcuts.searching.on_any_page" },
|
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
textTranslationKey: "ui.dialogs.shortcuts.searching.on_any_page",
|
||||||
|
},
|
||||||
|
{
|
||||||
shortcut: ["C"],
|
shortcut: ["C"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_command",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.searching.search_command",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: ["E"],
|
shortcut: ["E"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_entities",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.searching.search_entities",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: ["D"],
|
shortcut: ["D"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_devices",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.searching.search_devices",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "text",
|
textTranslationKey:
|
||||||
key: "ui.dialogs.shortcuts.searching.on_pages_with_tables",
|
"ui.dialogs.shortcuts.searching.on_pages_with_tables",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "F"],
|
shortcut: [CTRL_CMD, "F"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_in_table",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.searching.search_in_table",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "ui.dialogs.shortcuts.assist.title",
|
titleTranslationKey: "ui.dialogs.shortcuts.assist.title",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: ["A"],
|
shortcut: ["A"],
|
||||||
key: "ui.dialogs.shortcuts.assist.open_assist",
|
descriptionTranslationKey: "ui.dialogs.shortcuts.assist.open_assist",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "ui.dialogs.shortcuts.automation_script.title",
|
titleTranslationKey: "ui.dialogs.shortcuts.automation_script.title",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "C"],
|
shortcut: [CTRL_CMD, "C"],
|
||||||
key: "ui.dialogs.shortcuts.automation_script.copy",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.automation_script.copy",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "X"],
|
shortcut: [CTRL_CMD, "X"],
|
||||||
key: "ui.dialogs.shortcuts.automation_script.cut",
|
descriptionTranslationKey: "ui.dialogs.shortcuts.automation_script.cut",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "del"],
|
|
||||||
key: "ui.dialogs.shortcuts.automation_script.delete",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "V"],
|
|
||||||
key: "ui.dialogs.shortcuts.automation_script.paste",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, "S"],
|
|
||||||
key: "ui.dialogs.shortcuts.automation_script.save",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "ui.dialogs.shortcuts.charts.title",
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [CTRL_CMD, { key: "ui.dialogs.shortcuts.shortcuts.drag" }],
|
|
||||||
key: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "shortcut",
|
|
||||||
shortcut: [
|
shortcut: [
|
||||||
CTRL_CMD,
|
CTRL_CMD,
|
||||||
{ key: "ui.dialogs.shortcuts.shortcuts.scroll_wheel" },
|
{ shortcutTranslationKey: "ui.dialogs.shortcuts.keys.del" },
|
||||||
],
|
],
|
||||||
key: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.automation_script.delete",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
shortcut: [CTRL_CMD, "V"],
|
||||||
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.double_click" }],
|
descriptionTranslationKey:
|
||||||
key: "ui.dialogs.shortcuts.charts.double_click",
|
"ui.dialogs.shortcuts.automation_script.paste",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shortcut: [CTRL_CMD, "S"],
|
||||||
|
descriptionTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.automation_script.save",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "ui.dialogs.shortcuts.other.title",
|
titleTranslationKey: "ui.dialogs.shortcuts.charts.title",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
shortcut: [
|
||||||
|
CTRL_CMD,
|
||||||
|
{ shortcutTranslationKey: "ui.dialogs.shortcuts.shortcuts.drag" },
|
||||||
|
],
|
||||||
|
descriptionTranslationKey: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shortcut: [
|
||||||
|
CTRL_CMD,
|
||||||
|
{
|
||||||
|
shortcutTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.shortcuts.scroll_wheel",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
descriptionTranslationKey: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
shortcut: [
|
||||||
|
{
|
||||||
|
shortcutTranslationKey:
|
||||||
|
"ui.dialogs.shortcuts.shortcuts.double_click",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
descriptionTranslationKey: "ui.dialogs.shortcuts.charts.double_click",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
titleTranslationKey: "ui.dialogs.shortcuts.other.title",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
|
||||||
shortcut: ["M"],
|
shortcut: ["M"],
|
||||||
key: "ui.dialogs.shortcuts.other.my_link",
|
descriptionTranslationKey: "ui.dialogs.shortcuts.other.my_link",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -152,28 +164,28 @@ class DialogShortcuts extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _renderShortcut(
|
private _renderShortcut(
|
||||||
shortcuts: ShortcutString[],
|
shortcutKeys: ShortcutString[],
|
||||||
translationKey: LocalizeKeys
|
descriptionKey: LocalizeKeys
|
||||||
) {
|
) {
|
||||||
const keys = shortcuts.map((shortcut) =>
|
|
||||||
typeof shortcut === "string" ? shortcut : this.hass.localize(shortcut.key)
|
|
||||||
);
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="shortcut">
|
<div class="shortcut">
|
||||||
${keys.map(
|
${shortcutKeys.map(
|
||||||
(key) =>
|
(shortcutKey) =>
|
||||||
html`<span
|
html`<span
|
||||||
>${key === CTRL_CMD
|
>${shortcutKey === CTRL_CMD
|
||||||
? isMac
|
? isMac
|
||||||
? html`<ha-svg-icon
|
? html`<ha-svg-icon
|
||||||
.path=${mdiAppleKeyboardCommand}
|
.path=${mdiAppleKeyboardCommand}
|
||||||
></ha-svg-icon>`
|
></ha-svg-icon>`
|
||||||
: this.hass.localize("ui.panel.config.automation.editor.ctrl")
|
: this.hass.localize("ui.panel.config.automation.editor.ctrl")
|
||||||
: key}</span
|
: typeof shortcutKey === "string"
|
||||||
|
? shortcutKey
|
||||||
|
: this.hass.localize(
|
||||||
|
shortcutKey.shortcutTranslationKey
|
||||||
|
)}</span
|
||||||
>`
|
>`
|
||||||
)}
|
)}
|
||||||
${this.hass.localize(translationKey)}
|
${this.hass.localize(descriptionKey)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -197,16 +209,18 @@ class DialogShortcuts extends LitElement {
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
${_SHORTCUTS.map(
|
${_SHORTCUTS.map(
|
||||||
(section) => html`
|
(section) => html`
|
||||||
<h3>${this.hass.localize(section.key)}</h3>
|
<h3>${this.hass.localize(section.titleTranslationKey)}</h3>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
${section.items.map((item) => {
|
${section.items.map((item) => {
|
||||||
if (item.type === "text") {
|
if ("shortcut" in item) {
|
||||||
return html`<p>${this.hass.localize(item.key)}</p>`;
|
return this._renderShortcut(
|
||||||
|
(item as Shortcut).shortcut,
|
||||||
|
(item as Shortcut).descriptionTranslationKey
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (item.type === "shortcut") {
|
return html`<p>
|
||||||
return this._renderShortcut(item.shortcut, item.key);
|
${this.hass.localize((item as Text).textTranslationKey)}
|
||||||
}
|
</p>`;
|
||||||
return nothing;
|
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -2040,6 +2040,9 @@
|
|||||||
"title": "Shortcuts",
|
"title": "Shortcuts",
|
||||||
"enable_shortcuts_hint": "For keyboard shortcuts to work, make sure you have them enabled in your {user_profile}.",
|
"enable_shortcuts_hint": "For keyboard shortcuts to work, make sure you have them enabled in your {user_profile}.",
|
||||||
"enable_shortcuts_hint_user_profile": "user profile",
|
"enable_shortcuts_hint_user_profile": "user profile",
|
||||||
|
"keys": {
|
||||||
|
"del": "Del"
|
||||||
|
},
|
||||||
"shortcuts": {
|
"shortcuts": {
|
||||||
"double_click": "Double-click",
|
"double_click": "Double-click",
|
||||||
"scroll_wheel": "Scroll",
|
"scroll_wheel": "Scroll",
|
||||||
|
|||||||
Reference in New Issue
Block a user