mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add analytics translations (#15821)
* Add analytics translations * Move translations to panels * Fix learn more link
This commit is contained in:
parent
dd08909fef
commit
c0c83d3721
@ -1,11 +0,0 @@
|
|||||||
import { html } from "lit";
|
|
||||||
import { HomeAssistant } from "../types";
|
|
||||||
import { documentationUrl } from "../util/documentation-url";
|
|
||||||
|
|
||||||
export const analyticsLearnMore = (hass: HomeAssistant) => html`<a
|
|
||||||
.href=${documentationUrl(hass, "/integrations/analytics/")}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
>
|
|
||||||
How we process your data
|
|
||||||
</a>`;
|
|
@ -9,18 +9,7 @@ import "./ha-settings-row";
|
|||||||
import "./ha-switch";
|
import "./ha-switch";
|
||||||
import type { HaSwitch } from "./ha-switch";
|
import type { HaSwitch } from "./ha-switch";
|
||||||
|
|
||||||
const ADDITIONAL_PREFERENCES = [
|
const ADDITIONAL_PREFERENCES = ["usage", "statistics"] as const;
|
||||||
{
|
|
||||||
key: "usage",
|
|
||||||
title: "Usage",
|
|
||||||
description: "Details of what you use with Home Assistant",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "statistics",
|
|
||||||
title: "Statistical data",
|
|
||||||
description: "Counts containing total number of datapoints",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HASSDomEvents {
|
interface HASSDomEvents {
|
||||||
@ -34,15 +23,25 @@ export class HaAnalytics extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public analytics?: Analytics;
|
@property({ attribute: false }) public analytics?: Analytics;
|
||||||
|
|
||||||
|
@property({ attribute: "translation_key_panel" }) public translationKeyPanel:
|
||||||
|
| "page-onboarding"
|
||||||
|
| "config" = "config";
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const loading = this.analytics === undefined;
|
const loading = this.analytics === undefined;
|
||||||
const baseEnabled = !loading && this.analytics!.preferences.base;
|
const baseEnabled = !loading && this.analytics!.preferences.base;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading" data-for="base"> Basic analytics </span>
|
<span slot="heading" data-for="base">
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.base.title`
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
<span slot="description" data-for="base">
|
<span slot="description" data-for="base">
|
||||||
This includes information about your system.
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.base.description`
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
@change=${this._handleRowClick}
|
@change=${this._handleRowClick}
|
||||||
@ -57,25 +56,30 @@ export class HaAnalytics extends LitElement {
|
|||||||
(preference) =>
|
(preference) =>
|
||||||
html`
|
html`
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading" data-for=${preference.key}>
|
<span slot="heading" data-for=${preference}>
|
||||||
${preference.title}
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.title`
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span slot="description" data-for=${preference.key}>
|
<span slot="description" data-for=${preference}>
|
||||||
${preference.description}
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.${preference}.description`
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
@change=${this._handleRowClick}
|
@change=${this._handleRowClick}
|
||||||
.checked=${this.analytics?.preferences[preference.key]}
|
.checked=${this.analytics?.preferences[preference]}
|
||||||
.preference=${preference.key}
|
.preference=${preference}
|
||||||
name=${preference.key}
|
name=${preference}
|
||||||
>
|
>
|
||||||
</ha-switch>
|
</ha-switch>
|
||||||
${!baseEnabled
|
${!baseEnabled
|
||||||
? html`
|
? html`
|
||||||
<paper-tooltip animation-delay="0" position="right">
|
<paper-tooltip animation-delay="0" position="right">
|
||||||
You need to enable basic analytics for this option to be
|
${this.hass.localize(
|
||||||
available
|
`ui.panel.${this.translationKeyPanel}.analytics.need_base_enabled`
|
||||||
|
)}
|
||||||
</paper-tooltip>
|
</paper-tooltip>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@ -84,9 +88,15 @@ export class HaAnalytics extends LitElement {
|
|||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="heading" data-for="diagnostics"> Diagnostics </span>
|
<span slot="heading" data-for="diagnostics">
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.title`
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
<span slot="description" data-for="diagnostics">
|
<span slot="description" data-for="diagnostics">
|
||||||
Share crash reports when unexpected errors occur.
|
${this.hass.localize(
|
||||||
|
`ui.panel.${this.translationKeyPanel}.analytics.preferences.diagnostics.description`
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
@change=${this._handleRowClick}
|
@change=${this._handleRowClick}
|
||||||
@ -132,7 +142,7 @@ export class HaAnalytics extends LitElement {
|
|||||||
preferences[preference] = target.checked;
|
preferences[preference] = target.checked;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
ADDITIONAL_PREFERENCES.some((entry) => entry.key === preference) &&
|
ADDITIONAL_PREFERENCES.some((entry) => entry === preference) &&
|
||||||
target.checked
|
target.checked
|
||||||
) {
|
) {
|
||||||
preferences.base = true;
|
preferences.base = true;
|
||||||
|
@ -4,10 +4,10 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { LocalizeFunc } from "../common/translations/localize";
|
import { LocalizeFunc } from "../common/translations/localize";
|
||||||
import "../components/ha-analytics";
|
import "../components/ha-analytics";
|
||||||
import { analyticsLearnMore } from "../components/ha-analytics-learn-more";
|
|
||||||
import { Analytics, setAnalyticsPreferences } from "../data/analytics";
|
import { Analytics, setAnalyticsPreferences } from "../data/analytics";
|
||||||
import { onboardAnalyticsStep } from "../data/onboarding";
|
import { onboardAnalyticsStep } from "../data/onboarding";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
import { documentationUrl } from "../util/documentation-url";
|
||||||
|
|
||||||
@customElement("onboarding-analytics")
|
@customElement("onboarding-analytics")
|
||||||
class OnboardingAnalytics extends LitElement {
|
class OnboardingAnalytics extends LitElement {
|
||||||
@ -23,12 +23,9 @@ class OnboardingAnalytics extends LitElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<p>
|
<p>${this.hass.localize("ui.panel.page-onboarding.analytics.intro")}</p>
|
||||||
Share anonymized information from your installation to help make Home
|
|
||||||
Assistant better and help us convince manufacturers to add local control
|
|
||||||
and privacy-focused features.
|
|
||||||
</p>
|
|
||||||
<ha-analytics
|
<ha-analytics
|
||||||
|
translation_key_panel="page-onboarding"
|
||||||
@analytics-preferences-changed=${this._preferencesChanged}
|
@analytics-preferences-changed=${this._preferencesChanged}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.analytics=${this._analyticsDetails}
|
.analytics=${this._analyticsDetails}
|
||||||
@ -39,7 +36,13 @@ class OnboardingAnalytics extends LitElement {
|
|||||||
<mwc-button @click=${this._save} .disabled=${!this._analyticsDetails}>
|
<mwc-button @click=${this._save} .disabled=${!this._analyticsDetails}>
|
||||||
${this.localize("ui.panel.page-onboarding.analytics.finish")}
|
${this.localize("ui.panel.page-onboarding.analytics.finish")}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
${analyticsLearnMore(this.hass)}
|
<a
|
||||||
|
.href=${documentationUrl(this.hass, "/integrations/analytics/")}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
${this.hass.localize("ui.panel.page-onboarding.analytics.learn_more")}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import "../../../components/ha-analytics";
|
import "../../../components/ha-analytics";
|
||||||
import { analyticsLearnMore } from "../../../components/ha-analytics-learn-more";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-checkbox";
|
import "../../../components/ha-checkbox";
|
||||||
import "../../../components/ha-settings-row";
|
import "../../../components/ha-settings-row";
|
||||||
@ -21,6 +20,7 @@ import {
|
|||||||
} from "../../../data/analytics";
|
} from "../../../data/analytics";
|
||||||
import { haStyle } from "../../../resources/styles";
|
import { haStyle } from "../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
|
|
||||||
@customElement("ha-config-analytics")
|
@customElement("ha-config-analytics")
|
||||||
class ConfigAnalytics extends LitElement {
|
class ConfigAnalytics extends LitElement {
|
||||||
@ -41,12 +41,9 @@ class ConfigAnalytics extends LitElement {
|
|||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${error ? html`<div class="error">${error}</div>` : ""}
|
${error ? html`<div class="error">${error}</div>` : ""}
|
||||||
<p>
|
<p>${this.hass.localize("ui.panel.config.analytics.intro")}</p>
|
||||||
Share anonymized information from your installation to help make
|
|
||||||
Home Assistant better and help us convince manufacturers to add
|
|
||||||
local control and privacy-focused features.
|
|
||||||
</p>
|
|
||||||
<ha-analytics
|
<ha-analytics
|
||||||
|
translation_key_panel="config"
|
||||||
@analytics-preferences-changed=${this._preferencesChanged}
|
@analytics-preferences-changed=${this._preferencesChanged}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.analytics=${this._analyticsDetails}
|
.analytics=${this._analyticsDetails}
|
||||||
@ -60,7 +57,15 @@ class ConfigAnalytics extends LitElement {
|
|||||||
</mwc-button>
|
</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
<div class="footer">${analyticsLearnMore(this.hass)}</div>
|
<div class="footer">
|
||||||
|
<a
|
||||||
|
.href=${documentationUrl(this.hass, "/integrations/analytics/")}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
${this.hass.localize("ui.panel.config.analytics.learn_more")}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3753,7 +3753,28 @@
|
|||||||
},
|
},
|
||||||
"analytics": {
|
"analytics": {
|
||||||
"caption": "Analytics",
|
"caption": "Analytics",
|
||||||
"description": "Learn how to share data to improve Home Assistant"
|
"description": "Learn how to share data to improve Home Assistant",
|
||||||
|
"preferences": {
|
||||||
|
"base": {
|
||||||
|
"title": "Basic analytics",
|
||||||
|
"description": "This includes information about your system."
|
||||||
|
},
|
||||||
|
"usage": {
|
||||||
|
"title": "Usage",
|
||||||
|
"description": "Details of what you use with Home Assistant"
|
||||||
|
},
|
||||||
|
"statistics": {
|
||||||
|
"title": "Statistical data",
|
||||||
|
"description": "Counts containing total number of datapoints."
|
||||||
|
},
|
||||||
|
"diagnostics": {
|
||||||
|
"title": "Diagnostics",
|
||||||
|
"description": "Share crash reports when unexpected errors occur."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"need_base_enabled": "You need to enable basic analytics for this option to be available",
|
||||||
|
"learn_more": "How we process your data",
|
||||||
|
"intro": "Share anonymized information from your installation to help make Home Assistant better and help us convince manufacturers to add local control and privacy-focused features."
|
||||||
},
|
},
|
||||||
"network": {
|
"network": {
|
||||||
"caption": "Network",
|
"caption": "Network",
|
||||||
@ -5026,7 +5047,28 @@
|
|||||||
"finish": "Finish"
|
"finish": "Finish"
|
||||||
},
|
},
|
||||||
"analytics": {
|
"analytics": {
|
||||||
"finish": "Next"
|
"finish": "Next",
|
||||||
|
"preferences": {
|
||||||
|
"base": {
|
||||||
|
"title": "[%key:ui::panel::config::analytics::preferences::base::title%]",
|
||||||
|
"description": "[%key:ui::panel::config::analytics::preferences::base::description%]"
|
||||||
|
},
|
||||||
|
"usage": {
|
||||||
|
"title": "[%key:ui::panel::config::analytics::preferences::usage::title%]",
|
||||||
|
"description": "[%key:ui::panel::config::analytics::preferences::usage::description%]"
|
||||||
|
},
|
||||||
|
"statistics": {
|
||||||
|
"title": "[%key:ui::panel::config::analytics::preferences::statistics::title%]",
|
||||||
|
"description": "[%key:ui::panel::config::analytics::preferences::statistics::description%]"
|
||||||
|
},
|
||||||
|
"diagnostics": {
|
||||||
|
"title": "[%key:ui::panel::config::analytics::preferences::diagnostics::title%]",
|
||||||
|
"description": "[%key:ui::panel::config::analytics::preferences::diagnostics::description%]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"need_base_enabled": "[%key:ui::panel::config::analytics::need_base_enabled%]",
|
||||||
|
"learn_more": "[%key:ui::panel::config::analytics::learn_more%]",
|
||||||
|
"intro": "[%key:ui::panel::config::analytics::intro%]"
|
||||||
},
|
},
|
||||||
"restore": {
|
"restore": {
|
||||||
"description": "Alternatively you can restore from a previous backup.",
|
"description": "Alternatively you can restore from a previous backup.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user