@@ -158,6 +158,31 @@ def _service_schema(targeted: bool, custom: bool) -> vol.Schema:
158158}
159159
160160
161+ def check_extraneous_translation_fields (
162+ integration : Integration ,
163+ service_name : str ,
164+ strings : dict [str , Any ],
165+ service_schema : dict [str , Any ],
166+ ) -> None :
167+ """Check for extraneous translation fields."""
168+ if integration .core and "services" in strings :
169+ section_fields = set ()
170+ for field in service_schema .get ("fields" , {}).values ():
171+ if "fields" in field :
172+ # This is a section
173+ section_fields .update (field ["fields" ].keys ())
174+ translation_fields = {
175+ field
176+ for field in strings ["services" ][service_name ].get ("fields" , {})
177+ if field not in service_schema .get ("fields" , {})
178+ }
179+ for field in translation_fields - section_fields :
180+ integration .add_error (
181+ "services" ,
182+ f"Service { service_name } has a field { field } in the translations file that is not in the schema" ,
183+ )
184+
185+
161186def grep_dir (path : pathlib .Path , glob_pattern : str , search_pattern : str ) -> bool :
162187 """Recursively go through a dir and it's children and find the regex."""
163188 pattern = re .compile (search_pattern )
@@ -262,6 +287,10 @@ def validate_services(config: Config, integration: Integration) -> None: # noqa
262287 f"Service { service_name } has no description { error_msg_suffix } " ,
263288 )
264289
290+ check_extraneous_translation_fields (
291+ integration , service_name , strings , service_schema
292+ )
293+
265294 # The same check is done for the description in each of the fields of the
266295 # service schema.
267296 for field_name , field_schema in service_schema .get ("fields" , {}).items ():
0 commit comments