mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Make some parts of shortcuts in dialog translatable (#24955)
* Make some parts of shortcuts in dialog translatable * Adjust translations
This commit is contained in:
parent
d1465a79ae
commit
f0f60bae78
@ -14,9 +14,11 @@ interface Text {
|
|||||||
key: LocalizeKeys;
|
key: LocalizeKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ShortcutString = string | { key: LocalizeKeys };
|
||||||
|
|
||||||
interface Shortcut {
|
interface Shortcut {
|
||||||
type: "shortcut";
|
type: "shortcut";
|
||||||
shortcut: string[];
|
shortcut: ShortcutString[];
|
||||||
key: LocalizeKeys;
|
key: LocalizeKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ const _SHORTCUTS: Section[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: ["CRTL/CMND", "F"],
|
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" }, "F"],
|
||||||
key: "ui.dialogs.shortcuts.searching.search_in_table",
|
key: "ui.dialogs.shortcuts.searching.search_in_table",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -71,17 +73,23 @@ const _SHORTCUTS: Section[] = [
|
|||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: ["CRTL/CMND", "DRAG"],
|
shortcut: [
|
||||||
|
{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" },
|
||||||
|
{ key: "ui.dialogs.shortcuts.shortcuts.drag" },
|
||||||
|
],
|
||||||
key: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
key: "ui.dialogs.shortcuts.charts.drag_to_zoom",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: ["CRTL/CMND", "SCROLL WHEEL"],
|
shortcut: [
|
||||||
|
{ key: "ui.dialogs.shortcuts.shortcuts.ctrl_cmd" },
|
||||||
|
{ key: "ui.dialogs.shortcuts.shortcuts.scroll_wheel" },
|
||||||
|
],
|
||||||
key: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
key: "ui.dialogs.shortcuts.charts.scroll_to_zoom",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "shortcut",
|
type: "shortcut",
|
||||||
shortcut: ["DOUBLE CLICK"],
|
shortcut: [{ key: "ui.dialogs.shortcuts.shortcuts.double_click" }],
|
||||||
key: "ui.dialogs.shortcuts.charts.double_click",
|
key: "ui.dialogs.shortcuts.charts.double_click",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -113,10 +121,17 @@ class DialogShortcuts extends LitElement {
|
|||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderShortcut(shortcut: string[], translationKey: LocalizeKeys) {
|
private _renderShortcut(
|
||||||
|
shortcuts: ShortcutString[],
|
||||||
|
translationKey: 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">
|
||||||
${shortcut.map((key) => html` <span>${key}</span>`)}
|
${keys.map((key) => html` <span>${key.toUpperCase()}</span>`)}
|
||||||
${this.hass.localize(translationKey)}
|
${this.hass.localize(translationKey)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -1895,6 +1895,12 @@
|
|||||||
"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",
|
||||||
|
"shortcuts": {
|
||||||
|
"double_click": "Double-click",
|
||||||
|
"scroll_wheel": "Scroll",
|
||||||
|
"drag": "Drag",
|
||||||
|
"ctrl_cmd": "Ctrl/Cmd"
|
||||||
|
},
|
||||||
"searching": {
|
"searching": {
|
||||||
"title": "Searching",
|
"title": "Searching",
|
||||||
"on_any_page": "On any page",
|
"on_any_page": "On any page",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user