Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/panels/config/customize/ha-form-customize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import "@polymer/paper-item/paper-item";
import "@polymer/paper-listbox/paper-listbox";
import { html } from "@polymer/polymer/lib/utils/html-tag";
import { PolymerElement } from "@polymer/polymer/polymer-element";
import LocalizeMixin from "../../../mixins/localize-mixin";

import hassAttributeUtil from "../../../util/hass-attributes-util";
import "./ha-form-customize-attributes";

import { computeStateDomain } from "../../../common/entity/compute_state_domain";

class HaFormCustomize extends PolymerElement {
class HaFormCustomize extends LocalizeMixin(PolymerElement) {
static get template() {
return html`
<style include="iron-flex ha-style ha-form-style">
Expand All @@ -26,54 +27,52 @@ class HaFormCustomize extends PolymerElement {
if="[[computeShowWarning(localConfig, globalConfig)]]"
>
<div class="warning">
It seems that your configuration.yaml doesn't properly
[[localize('ui.panel.config.customize.warning.include_sentence')]]
<a
href="https://www.home-assistant.io/docs/configuration/customizing-devices/#customization-using-the-ui"
target="_blank"
>include customize.yaml</a
>[[localize('ui.panel.config.customize.warning.include_link')]]</a
>.<br />
Changes made here are written in it, but will not be applied after a
configuration reload unless the include is in place.
[[localize('ui.panel.config.customize.warning.not_applied')]]
</div>
</template>
<template is="dom-if" if="[[hasLocalAttributes]]">
<h4 class="attributes-text">
The following attributes are already set in customize.yaml<br />
[[localize('ui.panel.config.customize.attributes_customize')]]<br />
</h4>
<ha-form-customize-attributes
attributes="{{localAttributes}}"
></ha-form-customize-attributes>
</template>
<template is="dom-if" if="[[hasGlobalAttributes]]">
<h4 class="attributes-text">
The following attributes are customized from outside of
customize.yaml<br />
Possibly via a domain, a glob or a different include.
[[localize('ui.panel.config.customize.attributes_outside')]]<br />
[[localize('ui.panel.config.customize.different_include')]]
</h4>
<ha-form-customize-attributes
attributes="{{globalAttributes}}"
></ha-form-customize-attributes>
</template>
<template is="dom-if" if="[[hasExistingAttributes]]">
<h4 class="attributes-text">
The following attributes of the entity are set programatically.<br />
You can override them if you like.
[[localize('ui.panel.config.customize.attributes_set')]]<br />
[[localize('ui.panel.config.customize.attributes_override')]]
</h4>
<ha-form-customize-attributes
attributes="{{existingAttributes}}"
></ha-form-customize-attributes>
</template>
<template is="dom-if" if="[[hasNewAttributes]]">
<h4 class="attributes-text">
The following attributes weren't set. Set them if you like.
[[localize('ui.panel.config.customize.attributes_not_set')]]
</h4>
<ha-form-customize-attributes
attributes="{{newAttributes}}"
></ha-form-customize-attributes>
</template>
<div class="form-group">
<paper-dropdown-menu
label="Pick an attribute to override"
label="[[localize('ui.panel.config.customize.pick_attribute')]]"
class="flex"
dynamic-align=""
>
Expand Down
4 changes: 3 additions & 1 deletion src/panels/config/dashboard/ha-config-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class HaConfigDashboard extends NavigateMixin(LocalizeMixin(PolymerElement)) {

<template is='dom-if' if='[[!showAdvanced]]'>
<div class='promo-advanced'>
Missing config options? Enable advanced mode on <a href="/profile">your profile page.</a>
[[localize('ui.panel.profile.advanced_mode.hint_enable')]] <a
href="/profile"
>[[localize('ui.panel.profile.advanced_mode.link_profile_page')]]</a>.
</div>
</template>
</ha-config-section>
Expand Down
24 changes: 18 additions & 6 deletions src/panels/config/devices/ha-config-device-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ export class HaConfigDevicePage extends LitElement {

if (!device) {
return html`
<hass-error-screen error="Device not found."></hass-error-screen>
<hass-error-screen
error="${this.hass.localize(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a value is dynamic you can drop the " around them.

"ui.panel.config.devices.device_not_found"
)}"
></hass-error-screen>
`;
}

Expand All @@ -136,9 +140,11 @@ export class HaConfigDevicePage extends LitElement {
@click=${this._showSettings}
></paper-icon-button>
<ha-config-section .isWide=${!this.narrow}>
<span slot="header">Device info</span>
<span slot="header"
>${this.hass.localize("ui.panel.config.devices.info")}</span
>
<span slot="introduction">
Here are all the details of your device.
${this.hass.localize("ui.panel.config.devices.details")}
</span>
<ha-device-card
.hass=${this.hass}
Expand All @@ -149,7 +155,9 @@ export class HaConfigDevicePage extends LitElement {

${entities.length
? html`
<div class="header">Entities</div>
<div class="header">
${this.hass.localize("ui.panel.config.devices.entities")}
</div>
<ha-device-entities-card
.hass=${this.hass}
.entities=${entities}
Expand All @@ -161,7 +169,9 @@ export class HaConfigDevicePage extends LitElement {
this._conditions.length ||
this._actions.length
? html`
<div class="header">Automations</div>
<div class="header">
${this.hass.localize("ui.panel.config.devices.automations")}
</div>
${this._triggers.length
? html`
<ha-device-triggers-card
Expand Down Expand Up @@ -222,7 +232,9 @@ export class HaConfigDevicePage extends LitElement {
const renameEntityid =
this.showAdvanced &&
confirm(
"Do you also want to rename the entity id's of your entities?"
this.hass.localize(
"ui.panel.config.devices.confirm_rename_entity_ids"
)
);

const updateProms = entities.map((entity) => {
Expand Down
24 changes: 18 additions & 6 deletions src/panels/config/devices/ha-devices-data-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,33 +159,45 @@ export class HaDevicesDataTable extends LitElement {
}
: {
name: {
title: "Device",
title: this.hass.localize(
"ui.panel.config.devices.data_table.device"
),
sortable: true,
filterable: true,
direction: "asc",
},
manufacturer: {
title: "Manufacturer",
title: this.hass.localize(
"ui.panel.config.devices.data_table.manufacturer"
),
sortable: true,
filterable: true,
},
model: {
title: "Model",
title: this.hass.localize(
"ui.panel.config.devices.data_table.model"
),
sortable: true,
filterable: true,
},
area: {
title: "Area",
title: this.hass.localize(
"ui.panel.config.devices.data_table.area"
),
sortable: true,
filterable: true,
},
integration: {
title: "Integration",
title: this.hass.localize(
"ui.panel.config.devices.data_table.integration"
),
sortable: true,
filterable: true,
},
battery_entity: {
title: "Battery",
title: this.hass.localize(
"ui.panel.config.devices.data_table.battery"
),
sortable: true,
type: "numeric",
template: (batteryEntity: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class DialogEntityRegistryDetail extends LitElement {
${this.hass.localize(
"ui.panel.config.entity_registry.editor.enabled_description"
)}
<br />Note: this might not work yet with all integrations.
<br />${this.hass.localize(
"ui.panel.config.entity_registry.editor.note"
)}
</div>
</div>
</ha-switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class HaConfigEntryPage extends LitElement {

if (!configEntry) {
return html`
<hass-error-screen error="Integration not found."></hass-error-screen>
<hass-error-screen
error="${this.hass.localize(
"ui.panel.config.integrations.integration_not_found"
)}"
></hass-error-screen>
`;
}

Expand Down
20 changes: 15 additions & 5 deletions src/panels/custom/ha-panel-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,23 @@ export class HaPanelCustom extends UpdatingElement {
!["localhost", "127.0.0.1", location.hostname].includes(tempA.hostname)
) {
if (
!confirm(`Do you trust the external panel "${config.name}" at "${
tempA.href
}"?
!confirm(
`${this.hass.localize(
"ui.panel.custom.external_panel.question_trust",
"name",
config.name,
"link",
tempA.href
)}

It will have access to all data in Home Assistant.
${this.hass.localize(
"ui.panel.custom.external_panel.complete_access"
)}

(Check docs for the panel_custom component to hide this message)`)
(${this.hass.localize(
"ui.panel.custom.external_panel.hide_message"
)})`
)
) {
return;
}
Expand Down
5 changes: 3 additions & 2 deletions src/panels/logbook/ha-logbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { PolymerElement } from "@polymer/polymer/polymer-element";
import formatTime from "../../common/datetime/format_time";
import formatDate from "../../common/datetime/format_date";
import { EventsMixin } from "../../mixins/events-mixin";
import LocalizeMixin from "../../mixins/localize-mixin";
import { domainIcon } from "../../common/entity/domain_icon";
import { computeRTL } from "../../common/util/compute_rtl";

/*
* @appliesMixin EventsMixin
*/
class HaLogbook extends EventsMixin(PolymerElement) {
class HaLogbook extends LocalizeMixin(EventsMixin(PolymerElement)) {
static get template() {
return html`
<style include="iron-flex"></style>
Expand Down Expand Up @@ -55,7 +56,7 @@ class HaLogbook extends EventsMixin(PolymerElement) {
</style>

<template is="dom-if" if="[[!entries.length]]">
No logbook entries found.
[[localize('ui.panel.logbook.entries_not_found')]]
</template>

<template is="dom-repeat" items="[[entries]]">
Expand Down
46 changes: 42 additions & 4 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,19 @@
"picker": {
"header": "Customization",
"introduction": "Tweak per-entity attributes. Added/edited customizations will take effect immediately. Removed customizations will take effect when the entity is updated."
}
},
"warning": {
"include_sentence": "It seems that your configuration.yaml doesn't properly",
"include_link": "include customize.yaml",
Comment on lines +731 to +732
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should bring include to the other key and include the link as a variable in that string.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure what you mean by that. Do you want to pass the entire <a> into one translation string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

"include_sentence": "It seems that your configuration.yaml doesn't properly {link}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do:
"include_sentence": "It seems that your configuration.yaml doesn't properly include {customize_link}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like the way to do it properly 👍

Copy link
Copy Markdown
Member Author

@springstan springstan Oct 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oddly enough, I cannot pass the entire <a> into the string:

[[localize('ui.panel.config.customize.warning.include_sentence',
          'customize_link',
          '<a
          href="https://www.home-assistant.io/docs/configuration/customizing-devices/#customization-using-the-ui"
          target="_blank"
          >configuration.yaml</a>')]]

Just prints it out like that as the innerHTML of the div element.
Does the localize function filter html elements?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably... OK, never mind what I said.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how should I address this? Just leave it like that or is there any other option?

"not_applied": "Changes made here are written in it, but will not be applied after a configuration reload unless the include is in place."
},
"attributes_customize": "The following attributes are already set in customize.yaml",
"attributes_outside": "The following attributes are customized from outside of customize.yaml",
"different_include": "Possibly via a domain, a glob or a different include.",
"attributes_set": "The following attributes of the entity are set programmatically.",
"attributes_override": "You can override them if you like.",
"attributes_not_set": "The following attributes weren't set. Set them if you like.",
"pick_attribute": "Pick an attribute to override"
},
"automation": {
"caption": "Automation",
Expand Down Expand Up @@ -1131,6 +1143,20 @@
"actions": {
"caption": "When something is triggered..."
}
},
"device_not_found": "Device not found.",
"info": "Device info",
"details": "Here are all the details of your device.",
"entities": "Entities",
"automations": "Automations",
"confirm_rename_entity_ids": "Do you also want to rename the entity id's of your entities?",
"data_table": {
"device": "Device",
"manufacturer": "Manufacturer",
"model": "Model",
"area": "Area",
"integration": "Integration",
"battery": "Battery"
}
},
"entity_registry": {
Expand Down Expand Up @@ -1158,7 +1184,8 @@
"delete": "DELETE",
"confirm_delete": "Are you sure you want to delete this entry?",
"confirm_delete2": "Deleting an entry will not remove the entity from Home Assistant. To do this, you will need to remove the integration '{platform}' from Home Assistant.",
"update": "UPDATE"
"update": "UPDATE",
"note": "Note: this might not work yet with all integrations."
}
},
"person": {
Expand Down Expand Up @@ -1198,6 +1225,7 @@
"home_assistant_website": "Home Assistant website",
"configure": "Configure",
"none": "Nothing configured yet",
"integration_not_found": "Integration not found.",
"config_entry": {
"settings_button": "Edit settings for {integration}",
"system_options_button": "System options for {integration}",
Expand Down Expand Up @@ -1363,7 +1391,8 @@
},
"logbook": {
"showing_entries": "[%key:ui::panel::history::showing_entries%]",
"period": "Period"
"period": "Period",
"entries_not_found": "No logbook entries found."
},
"lovelace": {
"cards": {
Expand Down Expand Up @@ -1643,7 +1672,9 @@
},
"advanced_mode": {
"title": "Advanced Mode",
"description": "Home Assistant hides advanced features and options by default. You can make these features accessible by checking this toggle. This is a user-specific setting and does not impact other users using Home Assistant."
"description": "Home Assistant hides advanced features and options by default. You can make these features accessible by checking this toggle. This is a user-specific setting and does not impact other users using Home Assistant.",
"hint_enable": "Missing config options? Enable advanced mode on",
"link_profile_page": "your profile page"
},
"refresh_tokens": {
"header": "Refresh Tokens",
Expand Down Expand Up @@ -1952,6 +1983,13 @@
"more_integrations": "More",
"finish": "Finish"
}
},
"custom": {
"external_panel": {
"question_trust": "Do you trust the external panel {name} at {link}?",
"complete_access": "It will have access to all data in Home Assistant.",
"hide_message": "Check docs for the panel_custom component to hide this message"
}
}
}
}
Expand Down