From ce382a39d056d9f3a6210e1d17d03171f8bca627 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 21 Jul 2021 23:37:33 -0700 Subject: [PATCH] Block title in strings.json unless internal or allowed (#53304) --- homeassistant/components/airnow/strings.json | 1 - .../components/apple_tv/strings.json | 1 - .../components/bosch_shc/strings.json | 3 +- .../components/climacell/strings.json | 1 - homeassistant/components/foscam/strings.json | 1 - .../components/habitica/strings.json | 33 +++++++------ .../components/home_plus_control/strings.json | 1 - .../components/kostal_plenticore/strings.json | 3 +- homeassistant/components/mazda/strings.json | 46 +++++++++---------- .../components/mysensors/strings.json | 1 - homeassistant/components/neato/strings.json | 5 +- homeassistant/components/picnic/strings.json | 3 +- homeassistant/components/sia/strings.json | 1 - .../components/srp_energy/strings.json | 1 - .../components/syncthing/strings.json | 1 - homeassistant/components/wallbox/strings.json | 3 +- .../components/zwave_js/strings.json | 3 +- script/hassfest/model.py | 10 ++++ script/hassfest/translations.py | 28 +++++++++++ 19 files changed, 83 insertions(+), 63 deletions(-) diff --git a/homeassistant/components/airnow/strings.json b/homeassistant/components/airnow/strings.json index a73ad6d179c..9fc5bd3bccc 100644 --- a/homeassistant/components/airnow/strings.json +++ b/homeassistant/components/airnow/strings.json @@ -1,5 +1,4 @@ { - "title": "AirNow", "config": { "step": { "user": { diff --git a/homeassistant/components/apple_tv/strings.json b/homeassistant/components/apple_tv/strings.json index 00dd92cac89..d9fe17863dd 100644 --- a/homeassistant/components/apple_tv/strings.json +++ b/homeassistant/components/apple_tv/strings.json @@ -1,5 +1,4 @@ { - "title": "Apple TV", "config": { "flow_title": "{name}", "step": { diff --git a/homeassistant/components/bosch_shc/strings.json b/homeassistant/components/bosch_shc/strings.json index e7f090a4e1b..15fb061ef2b 100644 --- a/homeassistant/components/bosch_shc/strings.json +++ b/homeassistant/components/bosch_shc/strings.json @@ -1,5 +1,4 @@ { - "title": "Bosch SHC", "config": { "step": { "user": { @@ -35,4 +34,4 @@ }, "flow_title": "Bosch SHC: {name}" } -} \ No newline at end of file +} diff --git a/homeassistant/components/climacell/strings.json b/homeassistant/components/climacell/strings.json index f4347d254b7..44021f4b6d0 100644 --- a/homeassistant/components/climacell/strings.json +++ b/homeassistant/components/climacell/strings.json @@ -1,5 +1,4 @@ { - "title": "ClimaCell", "config": { "step": { "user": { diff --git a/homeassistant/components/foscam/strings.json b/homeassistant/components/foscam/strings.json index 5c0622af9d1..14aa88b7952 100644 --- a/homeassistant/components/foscam/strings.json +++ b/homeassistant/components/foscam/strings.json @@ -1,5 +1,4 @@ { - "title": "Foscam", "config": { "step": { "user": { diff --git a/homeassistant/components/habitica/strings.json b/homeassistant/components/habitica/strings.json index 868d024b02e..d25b840d761 100644 --- a/homeassistant/components/habitica/strings.json +++ b/homeassistant/components/habitica/strings.json @@ -1,20 +1,19 @@ { - "config": { - "error": { - "invalid_credentials": "[%key:common::config_flow::error::invalid_auth%]", - "unknown": "[%key:common::config_flow::error::unknown%]" - }, - "step": { - "user": { - "data": { - "url": "[%key:common::config_flow::data::url%]", - "name": "Override for Habitica’s username. Will be used for service calls", - "api_user": "Habitica’s API user ID", - "api_key": "[%key:common::config_flow::data::api_key%]" - }, - "description": "Connect your Habitica profile to allow monitoring of your user's profile and tasks. Note that api_id and api_key must be gotten from https://habitica.com/user/settings/api" - } - } + "config": { + "error": { + "invalid_credentials": "[%key:common::config_flow::error::invalid_auth%]", + "unknown": "[%key:common::config_flow::error::unknown%]" }, - "title": "Habitica" + "step": { + "user": { + "data": { + "url": "[%key:common::config_flow::data::url%]", + "name": "Override for Habitica’s username. Will be used for service calls", + "api_user": "Habitica’s API user ID", + "api_key": "[%key:common::config_flow::data::api_key%]" + }, + "description": "Connect your Habitica profile to allow monitoring of your user's profile and tasks. Note that api_id and api_key must be gotten from https://habitica.com/user/settings/api" + } + } + } } diff --git a/homeassistant/components/home_plus_control/strings.json b/homeassistant/components/home_plus_control/strings.json index c991c9e0279..9e860b397fb 100644 --- a/homeassistant/components/home_plus_control/strings.json +++ b/homeassistant/components/home_plus_control/strings.json @@ -1,5 +1,4 @@ { - "title": "Legrand Home+ Control", "config": { "step": { "pick_implementation": { diff --git a/homeassistant/components/kostal_plenticore/strings.json b/homeassistant/components/kostal_plenticore/strings.json index 771c3ada744..30ce5af5a6c 100644 --- a/homeassistant/components/kostal_plenticore/strings.json +++ b/homeassistant/components/kostal_plenticore/strings.json @@ -1,5 +1,4 @@ { - "title": "Kostal Plenticore Solar Inverter", "config": { "step": { "user": { @@ -18,4 +17,4 @@ "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } } -} \ No newline at end of file +} diff --git a/homeassistant/components/mazda/strings.json b/homeassistant/components/mazda/strings.json index a7bed8725af..d2cc1bcfec9 100644 --- a/homeassistant/components/mazda/strings.json +++ b/homeassistant/components/mazda/strings.json @@ -1,26 +1,24 @@ { - "config": { - "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_account%]", - "reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]" - }, - "error": { - "account_locked": "Account locked. Please try again later.", - "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", - "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", - "unknown": "[%key:common::config_flow::error::unknown%]" - }, - "step": { - "user": { - "data": { - "email": "[%key:common::config_flow::data::email%]", - "password": "[%key:common::config_flow::data::password%]", - "region": "Region" - }, - "description": "Please enter the email address and password you use to log into the MyMazda mobile app.", - "title": "Mazda Connected Services - Add Account" - } - } + "config": { + "abort": { + "already_configured": "[%key:common::config_flow::abort::already_configured_account%]", + "reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]" }, - "title": "Mazda Connected Services" -} \ No newline at end of file + "error": { + "account_locked": "Account locked. Please try again later.", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", + "unknown": "[%key:common::config_flow::error::unknown%]" + }, + "step": { + "user": { + "data": { + "email": "[%key:common::config_flow::data::email%]", + "password": "[%key:common::config_flow::data::password%]", + "region": "Region" + }, + "description": "Please enter the email address and password you use to log into the MyMazda mobile app." + } + } + } +} diff --git a/homeassistant/components/mysensors/strings.json b/homeassistant/components/mysensors/strings.json index 54821877b4f..d7722e565cb 100644 --- a/homeassistant/components/mysensors/strings.json +++ b/homeassistant/components/mysensors/strings.json @@ -1,5 +1,4 @@ { - "title": "MySensors", "config": { "step": { "user": { diff --git a/homeassistant/components/neato/strings.json b/homeassistant/components/neato/strings.json index 21af0f91d17..20848ccff08 100644 --- a/homeassistant/components/neato/strings.json +++ b/homeassistant/components/neato/strings.json @@ -18,6 +18,5 @@ "create_entry": { "default": "[%key:common::config_flow::create_entry::authenticated%]" } - }, - "title": "Neato Botvac" -} \ No newline at end of file + } +} diff --git a/homeassistant/components/picnic/strings.json b/homeassistant/components/picnic/strings.json index d43a91fbb0c..7fbd5e9bef6 100644 --- a/homeassistant/components/picnic/strings.json +++ b/homeassistant/components/picnic/strings.json @@ -1,5 +1,4 @@ { - "title": "Picnic", "config": { "step": { "user": { @@ -19,4 +18,4 @@ "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } } -} \ No newline at end of file +} diff --git a/homeassistant/components/sia/strings.json b/homeassistant/components/sia/strings.json index f837d41056a..fe648c24e75 100644 --- a/homeassistant/components/sia/strings.json +++ b/homeassistant/components/sia/strings.json @@ -1,5 +1,4 @@ { - "title": "SIA Alarm Systems", "config": { "step": { "user": { diff --git a/homeassistant/components/srp_energy/strings.json b/homeassistant/components/srp_energy/strings.json index 8dce61229a9..3dddd961194 100644 --- a/homeassistant/components/srp_energy/strings.json +++ b/homeassistant/components/srp_energy/strings.json @@ -1,5 +1,4 @@ { - "title": "SRP Energy", "config": { "step": { "user": { diff --git a/homeassistant/components/syncthing/strings.json b/homeassistant/components/syncthing/strings.json index 1781df56f1e..36d1a688a70 100644 --- a/homeassistant/components/syncthing/strings.json +++ b/homeassistant/components/syncthing/strings.json @@ -1,5 +1,4 @@ { - "title": "Syncthing", "config": { "step": { "user": { diff --git a/homeassistant/components/wallbox/strings.json b/homeassistant/components/wallbox/strings.json index 63fc5d89e85..6824a1343fc 100644 --- a/homeassistant/components/wallbox/strings.json +++ b/homeassistant/components/wallbox/strings.json @@ -1,5 +1,4 @@ { - "title": "Wallbox", "config": { "step": { "user": { @@ -19,4 +18,4 @@ "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } } -} \ No newline at end of file +} diff --git a/homeassistant/components/zwave_js/strings.json b/homeassistant/components/zwave_js/strings.json index 3d5aa277943..628451a6215 100644 --- a/homeassistant/components/zwave_js/strings.json +++ b/homeassistant/components/zwave_js/strings.json @@ -1,5 +1,4 @@ { - "title": "Z-Wave JS", "config": { "step": { "manual": { @@ -113,4 +112,4 @@ "value": "Current value of a Z-Wave Value" } } -} \ No newline at end of file +} diff --git a/script/hassfest/model.py b/script/hassfest/model.py index 59d75be5c4a..b20df6ea42f 100644 --- a/script/hassfest/model.py +++ b/script/hassfest/model.py @@ -86,6 +86,16 @@ class Integration: """Return if integration is disabled.""" return self.manifest.get("disabled") + @property + def name(self) -> str: + """Return name of the integration.""" + return self.manifest["name"] + + @property + def quality_scale(self) -> str: + """Return quality scale of the integration.""" + return self.manifest.get("quality_scale") + @property def requirements(self) -> list[str]: """List of requirements.""" diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py index 4143d61ca5d..e24b37d71d9 100644 --- a/script/hassfest/translations.py +++ b/script/hassfest/translations.py @@ -21,6 +21,20 @@ REMOVED = 2 RE_REFERENCE = r"\[\%key:(.+)\%\]" +# Only allow translatino of integration names if they contain non-brand names +ALLOW_NAME_TRANSLATION = { + "cert_expiry", + "emulated_roku", + "garages_amsterdam", + "google_travel_time", + "homekit_controller", + "islamic_prayer_times", + "local_ip", + "nmap_tracker", + "rpi_power", + "waze_travel_time", +} + REMOVED_TITLE_MSG = ( "config.title key has been moved out of config and into the root of strings.json. " "Starting Home Assistant 0.109 you only need to define this key in the root " @@ -257,6 +271,20 @@ def validate_translation_file(config: Config, integration: Integration, all_stri if strings_file.name == "strings.json": find_references(strings, name, references) + if ( + integration.domain not in ALLOW_NAME_TRANSLATION + # Only enforce for core because custom integratinos can't be + # added to allow list. + and integration.core + and strings.get("title") == integration.name + and integration.quality_scale != "internal" + ): + integration.add_error( + "translations", + "Don't specify title in translation strings if it's a brand name " + "or add exception to ALLOW_NAME_TRANSLATION", + ) + platform_string_schema = gen_platform_strings_schema(config, integration) platform_strings = [integration.path.glob("strings.*.json")]