Update domain translation string (#5558)

This commit is contained in:
Paulus Schoutsen 2020-04-17 09:01:45 -07:00 committed by GitHub
parent b516f10a35
commit 97c454aa0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 58 deletions

View File

@ -21,7 +21,7 @@ export const integrationIssuesUrl = (domain: string) =>
`https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+${domain}%22`;
export const domainToName = (localize: LocalizeFunc, domain: string) =>
localize(`domain.${domain}`) || domain;
localize(`component.${domain}.title`) || domain;
export const fetchIntegrationManifests = (hass: HomeAssistant) =>
hass.callWS<IntegrationManifest[]>({ type: "manifest/list" });

View File

@ -12,6 +12,7 @@ import { PolymerChangedEvent } from "../../polymer-types";
import { haStyleDialog } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import { HaDomainTogglerDialogParams } from "./show-dialog-domain-toggler";
import { domainToName } from "../../data/integration";
@customElement("dialog-domain-toggler")
class DomainTogglerDialog extends LitElement {
@ -29,7 +30,7 @@ class DomainTogglerDialog extends LitElement {
}
const domains = this._params.domains
.map((domain) => [this.hass.localize(`domain.${domain}`), domain])
.map((domain) => [domainToName(this.hass.localize, domain), domain])
.sort();
return html`

View File

@ -10,6 +10,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import { PersitentNotificationEntity } from "../../data/persistent_notification";
import { HomeAssistant } from "../../types";
import "./notification-item-template";
import { domainToName } from "../../data/integration";
@customElement("configurator-notification-item")
export class HuiConfiguratorNotificationItem extends LitElement {
@ -24,7 +25,9 @@ export class HuiConfiguratorNotificationItem extends LitElement {
return html`
<notification-item-template>
<span slot="header">${this.hass.localize("domain.configurator")}</span>
<span slot="header">
${domainToName(this.hass.localize, "configurator")}
</span>
<div>
${this.hass.localize(

View File

@ -27,6 +27,7 @@ import { PolymerChangedEvent } from "../../../../polymer-types";
import { haStyleDialog } from "../../../../resources/styles";
import { HomeAssistant } from "../../../../types";
import { Placeholder, PlaceholderContainer } from "./dialog-thingtalk";
import { domainToName } from "../../../../data/integration";
declare global {
// for fire event
@ -320,7 +321,7 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
private _getLabel(domains: string[], deviceClasses?: string[]) {
return `${domains
.map((domain) => this.hass.localize(`domain.${domain}`))
.map((domain) => domainToName(this.hass.localize, domain))
.join(", ")}${
deviceClasses ? ` of type ${deviceClasses.join(", ")}` : ""
}`;
@ -410,7 +411,7 @@ export class ThingTalkPlaceholders extends SubscribeMixin(LitElement) {
if (entities.length === 0) {
// Should not happen because we filter the device picker on domain
this._error = `No ${placeholder.domains
.map((domain) => this.hass.localize(`domain.${domain}`))
.map((domain) => domainToName(this.hass.localize, domain))
.join(", ")} entities found in this device.`;
} else if (entities.length === 1) {
applyPatch(

View File

@ -12,6 +12,7 @@ import {
integrationIssuesUrl,
IntegrationManifest,
fetchIntegrationManifests,
domainToName,
} from "../../../data/integration";
import { HomeAssistant } from "../../../types";
@ -48,7 +49,7 @@ class IntegrationsCard extends LitElement {
/>
</td>
<td class="name">
${manifest?.name}<br />
${domainToName(this.hass.localize, domain)}<br />
<span class="domain">${domain}</span>
</td>
${!manifest

View File

@ -13,6 +13,7 @@ import {
SystemHealthInfo,
} from "../../../data/system_health";
import { HomeAssistant } from "../../../types";
import { domainToName } from "../../../data/integration";
const sortKeys = (a: string, b: string) => {
if (a === "homeassistant") {
@ -64,7 +65,7 @@ class SystemHealthCard extends LitElement {
}
if (domain !== "homeassistant") {
sections.push(
html` <h3>${this.hass.localize(`domain.${domain}`) || domain}</h3> `
html` <h3>${domainToName(this.hass.localize, domain)}</h3> `
);
}
sections.push(html`
@ -76,7 +77,7 @@ class SystemHealthCard extends LitElement {
}
return html`
<ha-card .header=${this.hass.localize("domain.system_health")}>
<ha-card .header=${domainToName(this.hass.localize, "system_health")}>
<div class="card-content">${sections}</div>
</ha-card>
`;

View File

@ -73,10 +73,7 @@ class DialogSystemLogDetail extends LitElement {
${integration
? html`
<br />
Integration:
${this._manifest
? this._manifest.name
: domainToName(this.hass.localize, integration)}
Integration: ${domainToName(this.hass.localize, integration)}
${!this._manifest ||
// Can happen with custom integrations
!this._manifest.documentation

View File

@ -41,6 +41,7 @@ import {
} from "../cards/types";
import { processEditorEntities } from "../editor/process-editor-entities";
import { LovelaceRowConfig, WeblinkConfig } from "../entity-rows/types";
import { domainToName } from "../../../data/integration";
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
const DOMAINS_BADGES = [
@ -301,7 +302,7 @@ const generateViewConfig = (
entities[entityId],
]),
{
title: localize(`domain.${domain}`),
title: domainToName(localize, domain),
}
)
);

View File

@ -25,6 +25,7 @@ import { loadLovelaceResources } from "./common/load-resources";
import { showSaveDialog } from "./editor/show-save-config-dialog";
import "./hui-root";
import { Lovelace } from "./types";
import { domainToName } from "../../data/integration";
(window as any).loadCardHelpers = () => import("./custom-card-helpers");
@ -113,7 +114,7 @@ class LovelacePanel extends LitElement {
if (state === "error") {
return html`
<hass-error-screen
title="${this.hass!.localize("domain.lovelace")}"
title="${domainToName(this.hass!.localize, "lovelace")}"
.error="${this._errorMsg}"
>
<mwc-button raised @click=${this._forceFetchConfig}>

View File

@ -1,48 +1,4 @@
{
"domain": {
"alarm_control_panel": "Alarm control panel",
"automation": "Automation",
"binary_sensor": "Binary sensor",
"calendar": "Calendar",
"camera": "Camera",
"climate": "Climate",
"configurator": "Configurator",
"conversation": "Conversation",
"cover": "Cover",
"device_tracker": "Device tracker",
"fan": "Fan",
"group": "Group",
"hassio": "Hass.io",
"history_graph": "History graph",
"homeassistant": "Home Assistant",
"image_processing": "Image processing",
"input_boolean": "Input boolean",
"input_datetime": "Input datetime",
"input_number": "Input number",
"input_select": "Input select",
"input_text": "Input text",
"light": "Light",
"lock": "Lock",
"lovelace": "Lovelace",
"mailbox": "Mailbox",
"media_player": "Media player",
"notify": "Notify",
"person": "Person",
"plant": "Plant",
"proximity": "Proximity",
"remote": "Remote",
"scene": "Scene",
"script": "Script",
"sensor": "Sensor",
"sun": "Sun",
"switch": "Switch",
"system_health": "System Health",
"updater": "Updater",
"vacuum": "Vacuum",
"weblink": "Weblink",
"zha": "ZHA",
"zwave": "Z-Wave"
},
"panel": {
"calendar": "Calendar",
"config": "Configuration",