Translations for logbook/history panels (#741)

* Translations for logbook/history panels

* Switch to base localize function

* Move periods to generic durations keys

These are going to end up part of a duration class of keys that will be
more widely used.
This commit is contained in:
Adam Mills 2017-12-22 14:22:13 -05:00 committed by GitHub
parent 1b66492db9
commit 097a8cfdc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 11 deletions

View File

@ -18,6 +18,8 @@ const outDir = workDir + '/output';
// should mirror the fragment definitions in polymer.json, so that we load // should mirror the fragment definitions in polymer.json, so that we load
// additional resources at equivalent points. // additional resources at equivalent points.
const TRANSLATION_FRAGMENTS = [ const TRANSLATION_FRAGMENTS = [
'history',
'logbook',
'shopping-list', 'shopping-list',
]; ];

View File

@ -14,6 +14,7 @@
<link rel="import" href="../../src/components/ha-menu-button.html"> <link rel="import" href="../../src/components/ha-menu-button.html">
<link rel="import" href="../../src/data/ha-state-history-data.html"> <link rel="import" href="../../src/data/ha-state-history-data.html">
<link rel="import" href="../../src/resources/ha-style.html"> <link rel="import" href="../../src/resources/ha-style.html">
<link rel='import' href='../../src/util/hass-mixins.html'>
<dom-module id="ha-panel-history"> <dom-module id="ha-panel-history">
<template> <template>
@ -52,7 +53,7 @@
<app-header slot="header" fixed> <app-header slot="header" fixed>
<app-toolbar> <app-toolbar>
<ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button> <ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button>
<div main-title>History</div> <div main-title>[[localize('panel.history')]]</div>
</app-toolbar> </app-toolbar>
</app-header> </app-header>
@ -61,22 +62,22 @@
<vaadin-date-picker <vaadin-date-picker
id='picker' id='picker'
value='{{_currentDate}}' value='{{_currentDate}}'
label='Showing entries for' label="[[localize('ui.panel.history.showing_entries')]]"
disabled='[[isLoadingData]]' disabled='[[isLoadingData]]'
></vaadin-date-picker> ></vaadin-date-picker>
<paper-dropdown-menu <paper-dropdown-menu
label-float label-float
label='Period' label="[[localize('ui.panel.history.period')]]"
disabled='[[isLoadingData]]' disabled='[[isLoadingData]]'
> >
<paper-listbox <paper-listbox
slot="dropdown-content" slot="dropdown-content"
selected="{{_periodIndex}}" selected="{{_periodIndex}}"
> >
<paper-item>1 day</paper-item> <paper-item>[[localize('ui.duration.day', 'count', 1)]]</paper-item>
<paper-item>3 days</paper-item> <paper-item>[[localize('ui.duration.day', 'count', 3)]]</paper-item>
<paper-item>1 week</paper-item> <paper-item>[[localize('ui.duration.week', 'count', 1)]]</paper-item>
</paper-listbox> </paper-listbox>
</paper-dropdown-menu> </paper-dropdown-menu>
</div> </div>
@ -91,7 +92,10 @@
</dom-module> </dom-module>
<script> <script>
class HaPanelHistory extends Polymer.Element { /*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class HaPanelHistory extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'ha-panel-history'; } static get is() { return 'ha-panel-history'; }
static get properties() { static get properties() {

View File

@ -12,6 +12,7 @@
<link rel="import" href="../../src/components/ha-menu-button.html"> <link rel="import" href="../../src/components/ha-menu-button.html">
<link rel="import" href="../../src/resources/ha-style.html"> <link rel="import" href="../../src/resources/ha-style.html">
<link rel='import' href='../../src/util/hass-mixins.html'>
<link rel="import" href="./ha-logbook.html"> <link rel="import" href="./ha-logbook.html">
<link rel="import" href="./ha-logbook-data.html"> <link rel="import" href="./ha-logbook-data.html">
@ -53,7 +54,7 @@
<app-header slot="header" fixed> <app-header slot="header" fixed>
<app-toolbar> <app-toolbar>
<ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button> <ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button>
<div main-title>Logbook</div> <div main-title>[[localize('panel.logbook')]]</div>
</app-toolbar> </app-toolbar>
</app-header> </app-header>
@ -61,13 +62,13 @@
<paper-spinner <paper-spinner
active='[[isLoading]]' active='[[isLoading]]'
hidden$='[[!isLoading]]' hidden$='[[!isLoading]]'
alt='Loading logbook entries' alt="[[localize('ui.common.loading')]]"
></paper-spinner> ></paper-spinner>
<vaadin-date-picker <vaadin-date-picker
id='picker' id='picker'
value='{{_currentDate}}' value='{{_currentDate}}'
label='Showing entries for' label="[[localize('ui.panel.logbook.showing_entries')]]"
disabled='[[isLoading]]' disabled='[[isLoading]]'
></vaadin-date-picker> ></vaadin-date-picker>
@ -78,7 +79,10 @@
</dom-module> </dom-module>
<script> <script>
class HaPanelLogbook extends Polymer.Element { /*
* @appliesMixin window.hassMixins.LocalizeMixin
*/
class HaPanelLogbook extends window.hassMixins.LocalizeMixin(Polymer.Element) {
static get is() { return 'ha-panel-logbook'; } static get is() { return 'ha-panel-logbook'; }
static get properties() { static get properties() {

View File

@ -274,11 +274,25 @@
} }
}, },
"ui": { "ui": {
"common": {
"loading": "Loading"
},
"duration": {
"day": "{count} {count, plural,\n one {day}\n other {days}\n}",
"week": "{count} {count, plural,\n one {week}\n other {weeks}\n}"
},
"sidebar": { "sidebar": {
"developer_tools": "Developer tools", "developer_tools": "Developer tools",
"log_out": "Log out" "log_out": "Log out"
}, },
"panel": { "panel": {
"history": {
"showing_entries": "Showing entries for",
"period": "Period"
},
"logbook": {
"showing_entries": "[%key:ui::panel::history::showing_entries%]"
},
"shopping-list": { "shopping-list": {
"clear_completed": "Clear completed", "clear_completed": "Clear completed",
"add_item": "Add item", "add_item": "Add item",