diff --git a/src/components/ha-country-picker.ts b/src/components/ha-country-picker.ts index 2c5091da1e..b2f4b8a6e3 100644 --- a/src/components/ha-country-picker.ts +++ b/src/components/ha-country-picker.ts @@ -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", diff --git a/src/onboarding/onboarding-core-config.ts b/src/onboarding/onboarding-core-config.ts index 3c1f968c39..c3386c4d3a 100644 --- a/src/onboarding/onboarding-core-config.ts +++ b/src/onboarding/onboarding-core-config.ts @@ -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( diff --git a/src/translations/en.json b/src/translations/en.json index fae9868f27..c93321dbb9 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -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",