Skip to content

Commit

Permalink
Localize hide/show password (#18607)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored Nov 10, 2023
1 parent 1d45cb7 commit 708ab2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/ha-form/ha-form-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import type {
HaFormStringData,
HaFormStringSchema,
} from "./types";
import { HomeAssistant } from "../../types";

const MASKED_FIELDS = ["password", "secret", "token"];

@customElement("ha-form-string")
export class HaFormString extends LitElement implements HaFormElement {
@property() public hass!: HomeAssistant;

@property() public schema!: HaFormStringSchema;

@property() public data!: HaFormStringData;
Expand Down Expand Up @@ -78,7 +81,11 @@ export class HaFormString extends LitElement implements HaFormElement {
return html`
<ha-icon-button
toggles
.label=${`${this.unmaskedPassword ? "Hide" : "Show"} password`}
.label=${this.hass.localize(
this.unmaskedPassword
? "ui.components.selectors.text.hide_password"
: "ui.components.selectors.text.show_password"
)}
@click=${this.toggleUnmaskedPassword}
.path=${this.unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>
Expand Down
6 changes: 5 additions & 1 deletion src/components/ha-selector/ha-selector-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export class HaTextSelector extends LitElement {
${this.selector.text?.type === "password"
? html`<ha-icon-button
toggles
.label=${`${this._unmaskedPassword ? "Hide" : "Show"} password`}
.label=${this.hass.localize(
this._unmaskedPassword
? "ui.components.selectors.text.hide_password"
: "ui.components.selectors.text.show_password"
)}
@click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>`
Expand Down
4 changes: 4 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@
"file": {
"upload_failed": "Upload failed",
"unknown_file": "Unknown file"
},
"text": {
"show_password": "Show password",
"hide_password": "Hide password"
}
},
"logbook": {
Expand Down

0 comments on commit 708ab2e

Please sign in to comment.