mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-04 01:10:33 -06:00
Add translations for home dashboard (#26763)
This commit is contained in:
parent
98390b3843
commit
0269540ee9
@ -29,8 +29,12 @@ export class HuiHomeDashboardStrategyEditor
|
||||
<ha-entities-picker
|
||||
.hass=${this.hass}
|
||||
.value=${this._config.favorite_entities || []}
|
||||
label="Favorite entities"
|
||||
placeholder="Add favorite entity"
|
||||
label=${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.strategy.home.favorite_entities"
|
||||
)}
|
||||
placeholder=${this.hass.localize(
|
||||
"ui.panel.lovelace.editor.strategy.home.add_favorite_entity"
|
||||
)}
|
||||
reorder
|
||||
allow-custom-entity
|
||||
@value-changed=${this._valueChanged}
|
||||
|
||||
@ -2,6 +2,7 @@ import type {
|
||||
EntityFilter,
|
||||
EntityFilterFunc,
|
||||
} from "../../../../../common/entity/entity_filter";
|
||||
import type { LocalizeFunc } from "../../../../../common/translations/localize";
|
||||
|
||||
export const HOME_SUMMARIES = [
|
||||
"lights",
|
||||
@ -10,16 +11,16 @@ export const HOME_SUMMARIES = [
|
||||
"media_players",
|
||||
] as const;
|
||||
|
||||
export type HomeSummaries = (typeof HOME_SUMMARIES)[number];
|
||||
export type HomeSummary = (typeof HOME_SUMMARIES)[number];
|
||||
|
||||
export const HOME_SUMMARIES_ICONS: Record<HomeSummaries, string> = {
|
||||
export const HOME_SUMMARIES_ICONS: Record<HomeSummary, string> = {
|
||||
lights: "mdi:lamps",
|
||||
climate: "mdi:home-thermometer",
|
||||
security: "mdi:security",
|
||||
media_players: "mdi:multimedia",
|
||||
};
|
||||
|
||||
export const HOME_SUMMARIES_FILTERS: Record<HomeSummaries, EntityFilter[]> = {
|
||||
export const HOME_SUMMARIES_FILTERS: Record<HomeSummary, EntityFilter[]> = {
|
||||
lights: [{ domain: "light", entity_category: "none" }],
|
||||
climate: [
|
||||
{ domain: "climate", entity_category: "none" },
|
||||
@ -90,3 +91,6 @@ export const findEntities = (
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
export const getSummaryLabel = (localize: LocalizeFunc, summary: HomeSummary) =>
|
||||
localize(`ui.panel.lovelace.strategy.home.summary_list.${summary}`);
|
||||
|
||||
@ -14,10 +14,11 @@ import type { HeadingCardConfig } from "../../cards/types";
|
||||
import { computeAreaTileCardConfig } from "../areas/helpers/areas-strategy-helper";
|
||||
import {
|
||||
findEntities,
|
||||
getSummaryLabel,
|
||||
HOME_SUMMARIES,
|
||||
HOME_SUMMARIES_FILTERS,
|
||||
HOME_SUMMARIES_ICONS,
|
||||
type HomeSummaries,
|
||||
type HomeSummary,
|
||||
} from "./helpers/home-summaries";
|
||||
|
||||
export interface HomeAreaViewStrategyConfig {
|
||||
@ -96,7 +97,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
acc[summary] = findEntities(areaEntities, filterFunctions);
|
||||
return acc;
|
||||
},
|
||||
{} as Record<HomeSummaries, string[]>
|
||||
{} as Record<HomeSummary, string[]>
|
||||
);
|
||||
|
||||
const {
|
||||
@ -110,7 +111,11 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
sections.push({
|
||||
type: "grid",
|
||||
cards: [
|
||||
computeHeadingCard("Lights", HOME_SUMMARIES_ICONS.lights, "lights"),
|
||||
computeHeadingCard(
|
||||
getSummaryLabel(hass.localize, "lights"),
|
||||
HOME_SUMMARIES_ICONS.lights,
|
||||
"lights"
|
||||
),
|
||||
...lights.map(computeTileCard),
|
||||
],
|
||||
});
|
||||
@ -121,7 +126,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
type: "grid",
|
||||
cards: [
|
||||
computeHeadingCard(
|
||||
"Climate",
|
||||
getSummaryLabel(hass.localize, "climate"),
|
||||
HOME_SUMMARIES_ICONS.climate,
|
||||
"climate"
|
||||
),
|
||||
@ -135,7 +140,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
type: "grid",
|
||||
cards: [
|
||||
computeHeadingCard(
|
||||
"Security",
|
||||
getSummaryLabel(hass.localize, "security"),
|
||||
HOME_SUMMARIES_ICONS.security,
|
||||
"security"
|
||||
),
|
||||
@ -149,7 +154,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
type: "grid",
|
||||
cards: [
|
||||
computeHeadingCard(
|
||||
"Media players",
|
||||
getSummaryLabel(hass.localize, "media_players"),
|
||||
HOME_SUMMARIES_ICONS.media_players,
|
||||
"media-players"
|
||||
),
|
||||
@ -229,9 +234,11 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
||||
const device = hass.devices[deviceId];
|
||||
let heading = "";
|
||||
if (device) {
|
||||
heading = computeDeviceName(device) || "Unnamed device";
|
||||
heading =
|
||||
computeDeviceName(device) ||
|
||||
hass.localize("ui.panel.lovelace.strategy.home.unamed_device");
|
||||
} else {
|
||||
heading = "Others";
|
||||
heading = hass.localize("ui.panel.lovelace.strategy.home.others");
|
||||
}
|
||||
|
||||
deviceSections.push({
|
||||
|
||||
@ -95,7 +95,10 @@ export class HomeClimateViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? floor.name : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? floor.name
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -116,7 +119,10 @@ export class HomeClimateViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? "Other areas" : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? hass.localize("ui.panel.lovelace.strategy.home.other_areas")
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -6,7 +6,10 @@ import type { LovelaceViewRawConfig } from "../../../../data/lovelace/config/vie
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import { getAreas } from "../areas/helpers/areas-strategy-helper";
|
||||
import type { LovelaceStrategyEditor } from "../types";
|
||||
import { HOME_SUMMARIES_ICONS } from "./helpers/home-summaries";
|
||||
import {
|
||||
getSummaryLabel,
|
||||
HOME_SUMMARIES_ICONS,
|
||||
} from "./helpers/home-summaries";
|
||||
import type { HomeAreaViewStrategyConfig } from "./home-area-view-strategy";
|
||||
import type { HomeMainViewStrategyConfig } from "./home-main-view-strategy";
|
||||
|
||||
@ -60,7 +63,7 @@ export class HomeDashboardStrategy extends ReactiveElement {
|
||||
});
|
||||
|
||||
const lightView = {
|
||||
title: "Lights",
|
||||
title: getSummaryLabel(hass.localize, "lights"),
|
||||
path: "lights",
|
||||
subview: true,
|
||||
strategy: {
|
||||
@ -70,7 +73,7 @@ export class HomeDashboardStrategy extends ReactiveElement {
|
||||
} satisfies LovelaceViewRawConfig;
|
||||
|
||||
const climateView = {
|
||||
title: "Climate",
|
||||
title: getSummaryLabel(hass.localize, "climate"),
|
||||
path: "climate",
|
||||
subview: true,
|
||||
strategy: {
|
||||
@ -80,7 +83,7 @@ export class HomeDashboardStrategy extends ReactiveElement {
|
||||
} satisfies LovelaceViewRawConfig;
|
||||
|
||||
const securityView = {
|
||||
title: "Security",
|
||||
title: getSummaryLabel(hass.localize, "security"),
|
||||
path: "security",
|
||||
subview: true,
|
||||
strategy: {
|
||||
@ -90,7 +93,7 @@ export class HomeDashboardStrategy extends ReactiveElement {
|
||||
} satisfies LovelaceViewRawConfig;
|
||||
|
||||
const mediaPlayersView = {
|
||||
title: "Media players",
|
||||
title: getSummaryLabel(hass.localize, "media_players"),
|
||||
path: "media-players",
|
||||
subview: true,
|
||||
strategy: {
|
||||
|
||||
@ -89,7 +89,10 @@ export class HomeLightsViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? floor.name : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? floor.name
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -110,7 +113,10 @@ export class HomeLightsViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? "Other areas" : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? hass.localize("ui.panel.lovelace.strategy.home.other_areas")
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -15,7 +15,10 @@ import type {
|
||||
WeatherForecastCardConfig,
|
||||
} from "../../cards/types";
|
||||
import { getAreas } from "../areas/helpers/areas-strategy-helper";
|
||||
import { HOME_SUMMARIES_ICONS } from "./helpers/home-summaries";
|
||||
import {
|
||||
getSummaryLabel,
|
||||
HOME_SUMMARIES_ICONS,
|
||||
} from "./helpers/home-summaries";
|
||||
|
||||
export interface HomeMainViewStrategyConfig {
|
||||
type: "home-main";
|
||||
@ -63,7 +66,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
{
|
||||
type: "heading",
|
||||
heading_style: "title",
|
||||
heading: "Areas",
|
||||
heading: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
...areas.map<AreaCardConfig>((area) =>
|
||||
computeAreaCard(area.area_id, hass)
|
||||
@ -108,12 +111,12 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: "Summaries",
|
||||
heading: hass.localize("ui.panel.lovelace.strategy.home.summaries"),
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
icon: HOME_SUMMARIES_ICONS.lights,
|
||||
name: "Lights",
|
||||
name: getSummaryLabel(hass.localize, "lights"),
|
||||
icon_height: "24px",
|
||||
grid_options: {
|
||||
rows: 2,
|
||||
@ -127,7 +130,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
{
|
||||
type: "button",
|
||||
icon: HOME_SUMMARIES_ICONS.climate,
|
||||
name: "Climate",
|
||||
name: getSummaryLabel(hass.localize, "climate"),
|
||||
icon_height: "30px",
|
||||
grid_options: {
|
||||
rows: 2,
|
||||
@ -141,7 +144,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
{
|
||||
type: "button",
|
||||
icon: HOME_SUMMARIES_ICONS.security,
|
||||
name: "Security",
|
||||
name: getSummaryLabel(hass.localize, "security"),
|
||||
icon_height: "30px",
|
||||
grid_options: {
|
||||
rows: 2,
|
||||
@ -155,7 +158,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
{
|
||||
type: "button",
|
||||
icon: HOME_SUMMARIES_ICONS.media_players,
|
||||
name: "Media Players",
|
||||
name: getSummaryLabel(hass.localize, "media_players"),
|
||||
icon_height: "30px",
|
||||
grid_options: {
|
||||
rows: 2,
|
||||
@ -232,7 +235,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
||||
card: {
|
||||
type: "markdown",
|
||||
text_only: true,
|
||||
content: "## Welcome {{user}}",
|
||||
content: `## ${hass.localize("ui.panel.lovelace.strategy.home.welcome_user", { user: "{{ user }}" })}`,
|
||||
} satisfies MarkdownCardConfig,
|
||||
},
|
||||
};
|
||||
|
||||
@ -87,7 +87,10 @@ export class HomeMMediaPlayersViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? floor.name : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? floor.name
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -108,7 +111,10 @@ export class HomeMMediaPlayersViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? "Other areas" : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? hass.localize("ui.panel.lovelace.strategy.home.other_areas")
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -95,7 +95,10 @@ export class HomeSecurityViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? floor.name : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? floor.name
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -116,7 +119,10 @@ export class HomeSecurityViewStrategy extends ReactiveElement {
|
||||
cards: [
|
||||
{
|
||||
type: "heading",
|
||||
heading: floorCount > 1 ? "Other areas" : "Areas",
|
||||
heading:
|
||||
floorCount > 1
|
||||
? hass.localize("ui.panel.lovelace.strategy.home.other_areas")
|
||||
: hass.localize("ui.panel.lovelace.strategy.home.areas"),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -6817,6 +6817,20 @@
|
||||
},
|
||||
"other_areas": "Other areas",
|
||||
"areas": "Areas"
|
||||
},
|
||||
"home": {
|
||||
"summary_list": {
|
||||
"climate": "Climate",
|
||||
"lights": "Lights",
|
||||
"security": "Security",
|
||||
"media_players": "Media players"
|
||||
},
|
||||
"welcome_user": "Welcome {user}",
|
||||
"summaries": "Summaries",
|
||||
"areas": "Areas",
|
||||
"other_areas": "Other areas",
|
||||
"unamed_device": "Unnamed device",
|
||||
"others": "Others"
|
||||
}
|
||||
},
|
||||
"cards": {
|
||||
@ -8176,6 +8190,10 @@
|
||||
"no_entities": "No entities in this group, the section will not be displayed",
|
||||
"use_compact_card": "Use compact card",
|
||||
"use_large_card": "Use large card"
|
||||
},
|
||||
"home": {
|
||||
"favorite_entities": "Favorite entities",
|
||||
"add_favorite_entity": "Add favorite entity"
|
||||
}
|
||||
},
|
||||
"view": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user