Localize hide/show password (#18607)

This commit is contained in:
karwosts
2023-11-10 09:12:36 -08:00
committed by GitHub
parent 1d45cb78fe
commit 708ab2ed69
3 changed files with 17 additions and 2 deletions

View File

@@ -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;
@@ -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>