Translated developer tools state page (#4039)

* Translated developer tools state page

* Fixed merge error by updating used icon in developer-tools-state.js
This commit is contained in:
springstan 2019-10-18 16:33:11 +02:00 committed by Bram Kragten
parent 67d8d48855
commit e2ac842690
2 changed files with 44 additions and 18 deletions

View File

@ -10,12 +10,14 @@ import "../../../components/entity/ha-entity-picker";
import "../../../components/ha-code-editor"; import "../../../components/ha-code-editor";
import "../../../resources/ha-style"; import "../../../resources/ha-style";
import { EventsMixin } from "../../../mixins/events-mixin"; import { EventsMixin } from "../../../mixins/events-mixin";
import LocalizeMixin from "../../../mixins/localize-mixin";
const ERROR_SENTINEL = {}; const ERROR_SENTINEL = {};
/* /*
* @appliesMixin EventsMixin * @appliesMixin EventsMixin
* @appliesMixin LocalizeMixin
*/ */
class HaPanelDevState extends EventsMixin(PolymerElement) { class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
static get template() { static get template() {
return html` return html`
<style include="ha-style"> <style include="ha-style">
@ -70,8 +72,8 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
<div class="inputs"> <div class="inputs">
<p> <p>
Set the representation of a device within Home Assistant.<br /> [[localize('ui.panel.developer-tools.tabs.states.description1')]]<br />
This will not communicate with the actual device. [[localize('ui.panel.developer-tools.tabs.states.description2')]]
</p> </p>
<ha-entity-picker <ha-entity-picker
@ -82,7 +84,7 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
allow-custom-entity allow-custom-entity
></ha-entity-picker> ></ha-entity-picker>
<paper-input <paper-input
label="State" label="[[localize('ui.panel.developer-tools.tabs.states.state')]]"
required required
autocapitalize="none" autocapitalize="none"
autocomplete="off" autocomplete="off"
@ -91,7 +93,9 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
value="{{_state}}" value="{{_state}}"
class="state-input" class="state-input"
></paper-input> ></paper-input>
<p>State attributes (YAML, optional)</p> <p>
[[localize('ui.panel.developer-tools.tabs.states.state_attributes')]]
</p>
<ha-code-editor <ha-code-editor
mode="yaml" mode="yaml"
value="[[_stateAttributes]]" value="[[_stateAttributes]]"
@ -99,45 +103,49 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
on-value-changed="_yamlChanged" on-value-changed="_yamlChanged"
></ha-code-editor> ></ha-code-editor>
<mwc-button on-click="handleSetState" disabled="[[!validJSON]]" raised <mwc-button on-click="handleSetState" disabled="[[!validJSON]]" raised
>Set State</mwc-button >[[localize('ui.panel.developer-tools.tabs.states.set_state')]]</mwc-button
> >
</div> </div>
<h1>Current entities</h1> <h1>
[[localize('ui.panel.developer-tools.tabs.states.current_entities')]]
</h1>
<table class="entities"> <table class="entities">
<tr> <tr>
<th>Entity</th> <th>[[localize('ui.panel.developer-tools.tabs.states.entity')]]</th>
<th>State</th> <th>[[localize('ui.panel.developer-tools.tabs.states.state')]]</th>
<th hidden$="[[narrow]]"> <th hidden$="[[narrow]]">
Attributes [[localize('ui.panel.developer-tools.tabs.states.attributes')]]
<paper-checkbox checked="{{_showAttributes}}"></paper-checkbox> <paper-checkbox checked="{{_showAttributes}}"></paper-checkbox>
</th> </th>
</tr> </tr>
<tr> <tr>
<th> <th>
<paper-input <paper-input
label="Filter entities" label="[[localize('ui.panel.developer-tools.tabs.states.filter_entities')]]"
type="search" type="search"
value="{{_entityFilter}}" value="{{_entityFilter}}"
></paper-input> ></paper-input>
</th> </th>
<th> <th>
<paper-input <paper-input
label="Filter states" label="[[localize('ui.panel.developer-tools.tabs.states.filter_states')]]"
type="search" type="search"
value="{{_stateFilter}}" value="{{_stateFilter}}"
></paper-input> ></paper-input>
</th> </th>
<th hidden$="[[!computeShowAttributes(narrow, _showAttributes)]]"> <th hidden$="[[!computeShowAttributes(narrow, _showAttributes)]]">
<paper-input <paper-input
label="Filter attributes" label="[[localize('ui.panel.developer-tools.tabs.states.filter_attributes')]]"
type="search" type="search"
value="{{_attributeFilter}}" value="{{_attributeFilter}}"
></paper-input> ></paper-input>
</th> </th>
</tr> </tr>
<tr hidden$="[[!computeShowEntitiesPlaceholder(_entities)]]"> <tr hidden$="[[!computeShowEntitiesPlaceholder(_entities)]]">
<td colspan="3">No entities</td> <td colspan="3">
[[localize('ui.panel.developer-tools.tabs.states.no_entities')]]
</td>
</tr> </tr>
<template is="dom-repeat" items="[[_entities]]" as="entity"> <template is="dom-repeat" items="[[_entities]]" as="entity">
<tr> <tr>
@ -145,8 +153,8 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
<paper-icon-button <paper-icon-button
on-click="entityMoreInfo" on-click="entityMoreInfo"
icon="hass:information-outline" icon="hass:information-outline"
alt="More Info" alt="[[localize('ui.panel.developer-tools.tabs.states.more_info')]]"
title="More Info" title="[[localize('ui.panel.developer-tools.tabs.states.more_info')]]"
> >
</paper-icon-button> </paper-icon-button>
<a href="#" on-click="entitySelected">[[entity.entity_id]]</a> <a href="#" on-click="entitySelected">[[entity.entity_id]]</a>
@ -244,7 +252,11 @@ class HaPanelDevState extends EventsMixin(PolymerElement) {
handleSetState() { handleSetState() {
if (!this._entityId) { if (!this._entityId) {
alert("Entity is a mandatory field"); alert(
this.hass.localize(
"ui.panel.developer-tools.tabs.states.alert_entity_field"
)
);
return; return;
} }
this.hass.callApi("POST", "states/" + this._entityId, { this.hass.callApi("POST", "states/" + this._entityId, {

View File

@ -1816,7 +1816,21 @@
"title": "Services" "title": "Services"
}, },
"states": { "states": {
"title": "States" "title": "States",
"description1": "Set the representation of a device within Home Assistant.",
"description2": "This will not communicate with the actual device.",
"entity": "Entity",
"state": "State",
"attributes": "Attributes",
"state_attributes": "State attributes (YAML, optional)",
"set_state": "Set State",
"current_entities": "Current entities",
"filter_entities": "Filter entities",
"filter_states": "Filter states",
"filter_attributes": "Filter attributes",
"no_entities": "No entities",
"more_info": "More Info",
"alert_entity_field": "Entity is a mandatory field"
}, },
"templates": { "templates": {
"title": "Template" "title": "Template"