Skip to content

Commit

Permalink
Fix custom statetexts
Browse files Browse the repository at this point in the history
Fix custom statetexts. They are translated by default, but translation may be forced off by adding a leading '_' to the text you want.
  • Loading branch information
tmjo committed Nov 5, 2022
1 parent 1e98a22 commit f553363
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/charger-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,17 @@ class ChargerCard extends LitElement {
}

//Localize and choose
status = status !== null ? this.loc(status, "status", this.brand) || this.statetext[status] || status : '';
if (this.statetext !== null && this.statetext !== undefined && typeof this.statetext === 'object' && status in this.statetext) {
// console.info("status: " + status + " loc_status: " + (this.loc(status, "status", this.brand) || status) + " statetext: " + this.statetext[status] + " loc_statetext: " + (this.loc(this.statetext[status], "status", this.brand) || this.statetext[status]));
if (this.statetext[status].substring(0, 1) == "_") { //Do not translate if leading _
status = this.statetext[status].substring(1);
} else {
status = this.loc(this.statetext[status], "status", this.brand) || this.statetext[status];
}
} else {
status = status !== null ? this.loc(status, "status", this.brand) || status : '';
}

substatus = substatus !== null ? this.loc(substatus, "substatus", this.brand) || substatus : '';

return html`
Expand Down

0 comments on commit f553363

Please sign in to comment.