mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-17 15:00:31 +00:00
Localize show_password in auth form (#19300)
* Localize show_password in auth form * changes from review
This commit is contained in:
@@ -19,13 +19,15 @@ import type {
|
||||
HaFormStringData,
|
||||
HaFormStringSchema,
|
||||
} from "./types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { LocalizeFunc, LocalizeKeys } from "../../common/translations/localize";
|
||||
|
||||
const MASKED_FIELDS = ["password", "secret", "token"];
|
||||
|
||||
@customElement("ha-form-string")
|
||||
export class HaFormString extends LitElement implements HaFormElement {
|
||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||
@property({ attribute: false }) public localize?: LocalizeFunc;
|
||||
|
||||
@property() public localizeBaseKey = "ui.components.selectors.text";
|
||||
|
||||
@property() public schema!: HaFormStringSchema;
|
||||
|
||||
@@ -81,11 +83,11 @@ export class HaFormString extends LitElement implements HaFormElement {
|
||||
return html`
|
||||
<ha-icon-button
|
||||
toggles
|
||||
.label=${this.hass?.localize(
|
||||
this.unmaskedPassword
|
||||
? "ui.components.selectors.text.hide_password"
|
||||
: "ui.components.selectors.text.show_password"
|
||||
) || (this.unmaskedPassword ? "Hide password" : "Show password")}
|
||||
.label=${this.localize?.(
|
||||
`${this.localizeBaseKey}.${
|
||||
this.unmaskedPassword ? "hide_password" : "show_password"
|
||||
}` as LocalizeKeys
|
||||
)}
|
||||
@click=${this.toggleUnmaskedPassword}
|
||||
.path=${this.unmaskedPassword ? mdiEyeOff : mdiEye}
|
||||
></ha-icon-button>
|
||||
|
||||
Reference in New Issue
Block a user