mirror of
https://github.com/Andre0512/hon.git
synced 2024-11-30 18:24:29 +01:00
Add script to check missing translations
This commit is contained in:
parent
0cd4db0839
commit
3c747f9602
46
scripts/check.py
Executable file
46
scripts/check.py
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from custom_components.hon.binary_sensor import BINARY_SENSORS
|
||||
from custom_components.hon.button import BUTTONS
|
||||
from custom_components.hon.climate import CLIMATES
|
||||
from custom_components.hon.fan import FANS
|
||||
from custom_components.hon.light import LIGHTS
|
||||
from custom_components.hon.number import NUMBERS
|
||||
from custom_components.hon.select import SELECTS
|
||||
from custom_components.hon.sensor import SENSORS
|
||||
from custom_components.hon.switch import SWITCHES
|
||||
|
||||
entities = {
|
||||
"binary_sensor": BINARY_SENSORS,
|
||||
"button": BUTTONS,
|
||||
"light": LIGHTS,
|
||||
"climate": CLIMATES,
|
||||
"number": NUMBERS,
|
||||
"select": SELECTS,
|
||||
"sensor": SENSORS,
|
||||
"fan": FANS,
|
||||
"switch": SWITCHES,
|
||||
}
|
||||
|
||||
|
||||
def get_missing_translation_keys():
|
||||
result = {}
|
||||
for entity_type, appliances in entities.items():
|
||||
for appliance, data in appliances.items():
|
||||
for entity in data:
|
||||
if entity.translation_key:
|
||||
continue
|
||||
key = f"{entity_type}.{entity.key}"
|
||||
result.setdefault(appliance, []).append(key)
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for appliance, data in sorted(get_missing_translation_keys().items()):
|
||||
for key in data:
|
||||
print(f"WARNING - {appliance} - Missing translation key for {key}")
|
@ -8,6 +8,7 @@ from pathlib import Path
|
||||
if __name__ == "__main__":
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from custom_components.hon.const import APPLIANCES
|
||||
from custom_components.hon.binary_sensor import BINARY_SENSORS
|
||||
from custom_components.hon.button import BUTTONS
|
||||
from custom_components.hon.light import LIGHTS
|
||||
@ -22,36 +23,18 @@ from custom_components.hon.switch import (
|
||||
HonSwitchEntityDescription,
|
||||
)
|
||||
|
||||
APPLIANCES = {
|
||||
"AC": "Air Conditioner",
|
||||
"AP": "Air Purifier",
|
||||
"AS": "Air Scanner",
|
||||
"DW": "Dish Washer",
|
||||
"HO": "Hood",
|
||||
"IH": "Induction Hob",
|
||||
"MW": "Microwave",
|
||||
"OV": "Oven",
|
||||
"REF": "Fridge",
|
||||
"RVC": "Robot Vacuum Cleaner",
|
||||
"TD": "Tumble Dryer",
|
||||
"WC": "Wine Cellar",
|
||||
"WD": "Washer Dryer",
|
||||
"WH": "Water Heater",
|
||||
"WM": "Washing Machine",
|
||||
}
|
||||
|
||||
ENTITY_CATEGORY_SORT = ["control", "config", "sensor"]
|
||||
|
||||
entities = {
|
||||
"binary_sensor": BINARY_SENSORS,
|
||||
"button": BUTTONS,
|
||||
"light": LIGHTS,
|
||||
"climate": CLIMATES,
|
||||
"number": NUMBERS,
|
||||
"select": SELECTS,
|
||||
"sensor": SENSORS,
|
||||
"switch": SWITCHES,
|
||||
"climate": CLIMATES,
|
||||
"fan": FANS,
|
||||
"light": LIGHTS,
|
||||
"switch": SWITCHES,
|
||||
}
|
||||
|
||||
result = {}
|
||||
|
Loading…
Reference in New Issue
Block a user