Skip to content

Commit

Permalink
Fix not localized 'unknown' text #33
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwroc committed Jun 15, 2020
1 parent 90a42eb commit 831db07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/battery-vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class BatteryViewModel {

this.name = this.config.name || entityData.attributes.friendly_name

this.level = this.getLevel(entityData);
this.level = this.getLevel(entityData, hass);

// must be called after getting battery level
this.charging = this.getChargingState(hass);
Expand All @@ -202,8 +202,8 @@ class BatteryViewModel {
* Gets battery level
* @param entityData Entity state data
*/
private getLevel(entityData: HassEntity): string {
const UnknownLevel = "Unknown";
private getLevel(entityData: HassEntity, hass: HomeAssistant): string {
const UnknownLevel = hass.localize("state.default.unknown");
let level: string;

if (this.config.attribute) {
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const getRelativeTime = (hass: HomeAssistant, rawDate: string): string =>

time = Math.round((Date.now() - time) / 1000); // convert to seconds diff

// https://github.com/yosilevy/home-assistant-polymer/blob/master/src/translations/en.json
let relativeTime = "";
if (time < 60) {
relativeTime = hass.localize("ui.components.relative_time.duration.second", "count", time);
Expand Down

0 comments on commit 831db07

Please sign in to comment.