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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -19,11 +19,14 @@ import type {
HaFormStringData, HaFormStringData,
HaFormStringSchema, HaFormStringSchema,
} from "./types"; } from "./types";
import { HomeAssistant } from "../../types";
const MASKED_FIELDS = ["password", "secret", "token"]; const MASKED_FIELDS = ["password", "secret", "token"];
@customElement("ha-form-string") @customElement("ha-form-string")
export class HaFormString extends LitElement implements HaFormElement { export class HaFormString extends LitElement implements HaFormElement {
@property() public hass!: HomeAssistant;
@property() public schema!: HaFormStringSchema; @property() public schema!: HaFormStringSchema;
@property() public data!: HaFormStringData; @property() public data!: HaFormStringData;
@ -78,7 +81,11 @@ export class HaFormString extends LitElement implements HaFormElement {
return html` return html`
<ha-icon-button <ha-icon-button
toggles 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} @click=${this.toggleUnmaskedPassword}
.path=${this.unmaskedPassword ? mdiEyeOff : mdiEye} .path=${this.unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button> ></ha-icon-button>

View File

@ -76,7 +76,11 @@ export class HaTextSelector extends LitElement {
${this.selector.text?.type === "password" ${this.selector.text?.type === "password"
? html`<ha-icon-button ? html`<ha-icon-button
toggles 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} @click=${this._toggleUnmaskedPassword}
.path=${this._unmaskedPassword ? mdiEyeOff : mdiEye} .path=${this._unmaskedPassword ? mdiEyeOff : mdiEye}
></ha-icon-button>` ></ha-icon-button>`

View File

@ -328,6 +328,10 @@
"file": { "file": {
"upload_failed": "Upload failed", "upload_failed": "Upload failed",
"unknown_file": "Unknown file" "unknown_file": "Unknown file"
},
"text": {
"show_password": "Show password",
"hide_password": "Hide password"
} }
}, },
"logbook": { "logbook": {