Skip to content

Commit 026ef25

Browse files
🌐 localize editor
1 parent 04b3117 commit 026ef25

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

src/elements/editor.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {loadHaComponents} from "../functions/hacks";
77
import {CardConfig, EntitiesRowConfig} from "../structs/config";
88
import {HomeAssistant} from "custom-card-helpers";
99
import {setHass} from "../globals";
10+
import localize from "../localization/localize";
1011

1112
const FORM_SCHEMA = [
1213
{
@@ -117,19 +118,6 @@ export class TodayCardEditor extends LitElement {
117118
}
118119

119120
private computeLabel(schema: Record<string, unknown>): string {
120-
switch (schema.name) {
121-
case "title":
122-
return "Title";
123-
case "advance":
124-
return "Advance (optional)";
125-
case "show_all_day_events":
126-
return "Show all day events";
127-
case "show_past_events":
128-
return "Show past events";
129-
case "temp_color":
130-
return "Fallback color";
131-
default:
132-
return "";
133-
}
121+
return localize(`config.label.${schema.name}`);
134122
};
135123
}

src/elements/entity-editor.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {repeat} from "lit/directives/repeat";
66
import {fireEvent} from "../functions/config";
77
import {HomeAssistant} from "custom-card-helpers";
88
import {EntitiesRowConfig} from "../structs/config";
9+
import localize from "../localization/localize";
910

1011
@customElement('today-card-entities-editor')
1112
export class TodayCardEntitiesEditor extends LitElement {
@@ -22,9 +23,7 @@ export class TodayCardEntitiesEditor extends LitElement {
2223
}
2324

2425
return html`
25-
<h3>
26-
Entities (required)
27-
</h3>
26+
<h3>${localize('config.label.entities')}</h3>
2827
<div class="entities">
2928
${repeat(
3029
this.entities,
@@ -38,15 +37,15 @@ export class TodayCardEntitiesEditor extends LitElement {
3837
<ha-color-picker
3938
class="color-picker"
4039
.hass=${this.hass}
41-
.label="Color"
40+
.label=${localize('config.label.color')}
4241
.value=${entity.color ?? ""}
4342
.includeNone=${true}
4443
.includeState=${false}
4544
.index=${index}
4645
@value-changed=${this.changeColor}
4746
></ha-color-picker>
4847
<ha-icon-button
49-
.label="Clear"
48+
.label=${localize('config.label.clear')}
5049
.path=${mdiClose}
5150
class="remove-icon"
5251
.index=${index}

src/localization/lang/de.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
"config": {
1414
"stub": {
1515
"title": "Heutiger Terminplan"
16+
},
17+
"label": {
18+
"title": "Titel",
19+
"advance": "Vorlauf (optional)",
20+
"fallback_color": "Standard-Farbe",
21+
"show_all_day_events": "Zeige ganztägige Termine",
22+
"show_past_events": "Zeige vergangene Termine",
23+
"entities": "Entitäten (benötigt)",
24+
"color": "Farbe",
25+
"clear": "Entfernen"
1626
}
1727
}
1828
}

src/localization/lang/en.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
"config": {
1414
"stub": {
1515
"title": "Today's Schedule"
16+
},
17+
"label": {
18+
"title": "Title",
19+
"advance": "Advance (optional)",
20+
"fallback_color": "Fallback Color",
21+
"show_all_day_events": "Show all day events",
22+
"show_past_events": "Show past events",
23+
"entities": "Entities (required)",
24+
"color": "Color",
25+
"clear": "Clear"
1626
}
1727
}
1828
}

0 commit comments

Comments
 (0)