Block title in strings.json unless internal or allowed (#53304)

This commit is contained in:
Paulus Schoutsen 2021-07-21 23:37:33 -07:00 committed by GitHub
parent b9a6ce77d1
commit ce382a39d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 83 additions and 63 deletions

View File

@ -1,5 +1,4 @@
{
"title": "AirNow",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "Apple TV",
"config": {
"flow_title": "{name}",
"step": {

View File

@ -1,5 +1,4 @@
{
"title": "Bosch SHC",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "ClimaCell",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "Foscam",
"config": {
"step": {
"user": {

View File

@ -15,6 +15,5 @@
"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"
}
}
},
"title": "Habitica"
}
}

View File

@ -1,5 +1,4 @@
{
"title": "Legrand Home+ Control",
"config": {
"step": {
"pick_implementation": {

View File

@ -1,5 +1,4 @@
{
"title": "Kostal Plenticore Solar Inverter",
"config": {
"step": {
"user": {

View File

@ -17,10 +17,8 @@
"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"
"description": "Please enter the email address and password you use to log into the MyMazda mobile app."
}
}
}
},
"title": "Mazda Connected Services"
}

View File

@ -1,5 +1,4 @@
{
"title": "MySensors",
"config": {
"step": {
"user": {

View File

@ -18,6 +18,5 @@
"create_entry": {
"default": "[%key:common::config_flow::create_entry::authenticated%]"
}
},
"title": "Neato Botvac"
}
}

View File

@ -1,5 +1,4 @@
{
"title": "Picnic",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "SIA Alarm Systems",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "SRP Energy",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "Syncthing",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "Wallbox",
"config": {
"step": {
"user": {

View File

@ -1,5 +1,4 @@
{
"title": "Z-Wave JS",
"config": {
"step": {
"manual": {

View File

@ -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."""

View File

@ -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")]