mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 13:56:35 +00:00
Set correct lang attribute (#5479)
* Set correct lang attribute * Update lit-localize-lite-mixin.ts * Update translations-mixin.ts * Remove lang="" * Move logic out of mixin
This commit is contained in:
parent
a71f42366a
commit
4f70ec7dc2
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
|
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
|
||||||
|
@ -123,6 +123,13 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
super.updated(changedProps);
|
||||||
|
if (changedProps.has("language")) {
|
||||||
|
document.querySelector("html")!.setAttribute("lang", this.language!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _fetchAuthProviders() {
|
private async _fetchAuthProviders() {
|
||||||
// Fetch auth providers
|
// Fetch auth providers
|
||||||
try {
|
try {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Home Assistant</title>
|
<title>Home Assistant</title>
|
||||||
<link rel="preload" href="<%= latestPageJS %>" as="script" crossorigin="use-credentials" />
|
<link rel="preload" href="<%= latestPageJS %>" as="script" crossorigin="use-credentials" />
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="preload" href="<%= latestCoreJS %>" as="script" crossorigin="use-credentials" />
|
<link rel="preload" href="<%= latestCoreJS %>" as="script" crossorigin="use-credentials" />
|
||||||
<link
|
<link
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Home Assistant</title>
|
<title>Home Assistant</title>
|
||||||
<link rel="preload" href="<%= latestPageJS %>" as="script" crossorigin="use-credentials" />
|
<link rel="preload" href="<%= latestPageJS %>" as="script" crossorigin="use-credentials" />
|
||||||
|
@ -19,23 +19,24 @@ export const litLocalizeLiteMixin = <T extends Constructor<LitElement>>(
|
|||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._initializeLocalizeLite();
|
this._initializeLocalizeLite();
|
||||||
this.localize = computeLocalize(
|
|
||||||
this.constructor.prototype,
|
|
||||||
this.language!,
|
|
||||||
this.resources!
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProperties: PropertyValues) {
|
protected updated(changedProperties: PropertyValues) {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
|
if (changedProperties.get("translationFragment")) {
|
||||||
|
this._initializeLocalizeLite();
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
changedProperties.has("language") ||
|
this.language &&
|
||||||
changedProperties.has("resources")
|
this.resources &&
|
||||||
|
(changedProperties.has("language") ||
|
||||||
|
changedProperties.has("resources"))
|
||||||
) {
|
) {
|
||||||
this.localize = computeLocalize(
|
this.localize = computeLocalize(
|
||||||
this.constructor.prototype,
|
this.constructor.prototype,
|
||||||
this.language!,
|
this.language,
|
||||||
this.resources!
|
this.resources
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,13 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
|
|||||||
this.addEventListener("onboarding-step", (ev) => this._handleStepDone(ev));
|
this.addEventListener("onboarding-step", (ev) => this._handleStepDone(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
super.updated(changedProps);
|
||||||
|
if (changedProps.has("language")) {
|
||||||
|
document.querySelector("html")!.setAttribute("lang", this.language!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _curStep() {
|
private _curStep() {
|
||||||
return this._steps ? this._steps.find((stp) => !stp.done) : undefined;
|
return this._steps ? this._steps.find((stp) => !stp.done) : undefined;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,11 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
|||||||
if (saveToBackend) {
|
if (saveToBackend) {
|
||||||
saveTranslationPreferences(this.hass, { language });
|
saveTranslationPreferences(this.hass, { language });
|
||||||
}
|
}
|
||||||
|
|
||||||
this._applyTranslations(this.hass);
|
this._applyTranslations(this.hass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _applyTranslations(hass: HomeAssistant) {
|
private _applyTranslations(hass: HomeAssistant) {
|
||||||
|
document.querySelector("html")!.setAttribute("lang", hass.language);
|
||||||
this.style.direction = computeRTL(hass) ? "rtl" : "ltr";
|
this.style.direction = computeRTL(hass) ? "rtl" : "ltr";
|
||||||
this._loadCoreTranslations(hass.language);
|
this._loadCoreTranslations(hass.language);
|
||||||
this._loadHassTranslations(hass.language);
|
this._loadHassTranslations(hass.language);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user