Update country picker dialog in onboarding (#24551)

* Update country picker dialog in onboarding

* Handle if language has no locale

* Don't fall back to NL
This commit is contained in:
Paulus Schoutsen 2025-03-08 09:40:22 -05:00 committed by GitHub
parent 1ac0092d4e
commit 6ed26407be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import "./ha-list-item";
import "./ha-select";
import type { HaSelect } from "./ha-select";
const COUNTRIES = [
export const COUNTRIES = [
"AD",
"AE",
"AF",

View File

@ -7,7 +7,7 @@ import { fireEvent } from "../common/dom/fire_event";
import type { LocalizeFunc } from "../common/translations/localize";
import "../components/ha-alert";
import "../components/ha-circular-progress";
import "../components/ha-country-picker";
import { COUNTRIES } from "../components/ha-country-picker";
import type { ConfigUpdateValues } from "../data/core";
import { saveCoreConfig } from "../data/core";
import { countryCurrency } from "../data/currency";
@ -131,6 +131,17 @@ class OnboardingCoreConfig extends LitElement {
this._save(ev);
return;
}
// Set suggested country
let suggested: string | undefined;
if (navigator.language) {
const lang = navigator.language.split("-").pop()!.toUpperCase();
if (COUNTRIES.includes(lang)) {
suggested = lang;
}
}
this._country = suggested;
fireEvent(this, "onboarding-progress", { increase: 0.5 });
await this.updateComplete;
setTimeout(

View File

@ -8234,7 +8234,7 @@
"osm_privacy_policy": "Privacy policy",
"title_location_detect": "Do you want us to detect your location?",
"intro_location_detect": "We can detect your location by making a one-time request to an external service.",
"country_intro": "We would like to know the country your home is in, so we can use the correct units for you.",
"country_intro": "We would like to know the country your home is in, so we can use the correct units.",
"location_name": "Name of your Home Assistant installation",
"location_name_default": "Home",
"address_label": "Search address",