added translation between states and loc

This commit is contained in:
Johannes
2022-05-28 22:58:23 +02:00
parent 02f1186fb8
commit 10655e6c35
2 changed files with 12 additions and 43 deletions

View File

@@ -26,7 +26,6 @@ translations = {
'operation': "Operasie", 'operation': "Operasie",
'fan_mode': "Waaier modus", 'fan_mode': "Waaier modus",
'heating': "Verhit", 'heating': "Verhit",
'heat': "Verhit",
}, },
'ar': { 'ar': {
'ACTIVATE': "تفعيل", 'ACTIVATE': "تفعيل",
@@ -55,7 +54,6 @@ translations = {
'operation': "الوضع", 'operation': "الوضع",
'fan_mode': "وضع المروحة", 'fan_mode': "وضع المروحة",
'heating': "تدفئة", 'heating': "تدفئة",
'heat': "تدفئة",
}, },
'bg': { 'bg': {
'ACTIVATE': "Активирай", 'ACTIVATE': "Активирай",
@@ -85,7 +83,6 @@ translations = {
'operation': "Режим", 'operation': "Режим",
'fan_mode': "Режим на вентилатора", 'fan_mode': "Режим на вентилатора",
'heating': "Отопление", 'heating': "Отопление",
'heat': "Отопление",
}, },
'ca': { 'ca': {
'PRESS': "Prem", 'PRESS': "Prem",
@@ -116,7 +113,6 @@ translations = {
'operation': "Funcionament", 'operation': "Funcionament",
'fan_mode': "Velocitat ventilador", 'fan_mode': "Velocitat ventilador",
'heating': "Escalfant", 'heating': "Escalfant",
'heat': "Escalfant",
}, },
'cs': { 'cs': {
'PRESS': "Stisknutí", 'PRESS': "Stisknutí",
@@ -147,7 +143,6 @@ translations = {
'operation': "Provoz", 'operation': "Provoz",
'fan_mode': "Režim ventilátoru", 'fan_mode': "Režim ventilátoru",
'heating': "Topení", 'heating': "Topení",
'heat': "Topení",
}, },
'da': { 'da': {
'PRESS': "Tryk", 'PRESS': "Tryk",
@@ -178,7 +173,6 @@ translations = {
'operation': "Drifttype", 'operation': "Drifttype",
'fan_mode': "Blæsertilstand", 'fan_mode': "Blæsertilstand",
'heating': "Opvarmning", 'heating': "Opvarmning",
'heat': "Opvarmning",
}, },
'de': { 'de': {
'PRESS': "Drücken", 'PRESS': "Drücken",
@@ -209,7 +203,6 @@ translations = {
'operation': "Aktion", 'operation': "Aktion",
'fan_mode': "Ventilator-Modus", 'fan_mode': "Ventilator-Modus",
'heating': "Heizung", 'heating': "Heizung",
'heat': "Heizung",
}, },
'el': { 'el': {
'PRESS': "Πατήστε", 'PRESS': "Πατήστε",
@@ -240,7 +233,6 @@ translations = {
'operation': "Λειτουργία", 'operation': "Λειτουργία",
'fan_mode': "Λειτουργία ανεμιστήρα", 'fan_mode': "Λειτουργία ανεμιστήρα",
'heating': "Θέρμανση", 'heating': "Θέρμανση",
'heat': "Θέρμανση",
}, },
'en': { 'en': {
'PRESS': "Press", 'PRESS': "Press",
@@ -271,7 +263,6 @@ translations = {
'operation': "Operation", 'operation': "Operation",
'fan_mode': "Fan mode", 'fan_mode': "Fan mode",
'heating': "Heating", 'heating': "Heating",
'heat': "Heating",
}, },
'es': { 'es': {
'PRESS': "Pulsa", 'PRESS': "Pulsa",
@@ -302,7 +293,6 @@ translations = {
'operation': "Modo", 'operation': "Modo",
'fan_mode': "Modo del ventilador", 'fan_mode': "Modo del ventilador",
'heating': "Calentando", 'heating': "Calentando",
'heat': "Calentando",
}, },
'et': { 'et': {
'PRESS': "Vajuta nuppu", 'PRESS': "Vajuta nuppu",
@@ -333,7 +323,6 @@ translations = {
'operation': "Töörežiim", 'operation': "Töörežiim",
'fan_mode': "Ventilaatori režiim", 'fan_mode': "Ventilaatori režiim",
'heating': "Küte", 'heating': "Küte",
'heat': "Küte",
}, },
'fa': { 'fa': {
'ACTIVATE': "فعال سازی", 'ACTIVATE': "فعال سازی",
@@ -362,7 +351,6 @@ translations = {
'operation': "عملیات", 'operation': "عملیات",
'fan_mode': "حالت فن", 'fan_mode': "حالت فن",
'heating': "گرمایش", 'heating': "گرمایش",
'heat': "گرمایش",
}, },
'fi': { 'fi': {
'PRESS': "Paina", 'PRESS': "Paina",
@@ -393,7 +381,6 @@ translations = {
'operation': "Toiminto", 'operation': "Toiminto",
'fan_mode': "Tuuletustila", 'fan_mode': "Tuuletustila",
'heating': "Lämmitys", 'heating': "Lämmitys",
'heat': "Lämmitys",
}, },
'fr': { 'fr': {
'PRESS': "Appui", 'PRESS': "Appui",
@@ -424,7 +411,6 @@ translations = {
'operation': "Opération", 'operation': "Opération",
'fan_mode': "Mode de ventilation", 'fan_mode': "Mode de ventilation",
'heating': "En chauffe", 'heating': "En chauffe",
'heat': "En chauffe",
}, },
'he': { 'he': {
'PRESS': "לחיצה", 'PRESS': "לחיצה",
@@ -455,7 +441,6 @@ translations = {
'operation': "פעולה", 'operation': "פעולה",
'fan_mode': "מצב מאורר", 'fan_mode': "מצב מאורר",
'heating': "חימום", 'heating': "חימום",
'heat': "חימום",
}, },
'hr': { 'hr': {
'ACTIVATE': "Aktivirati", 'ACTIVATE': "Aktivirati",
@@ -484,7 +469,6 @@ translations = {
'operation': "operacija", 'operation': "operacija",
'fan_mode': "Način rada s ventilatorom", 'fan_mode': "Način rada s ventilatorom",
'heating': "Grijanje", 'heating': "Grijanje",
'heat': "Grijanje",
}, },
'hu': { 'hu': {
'PRESS': "Gombnyomás", 'PRESS': "Gombnyomás",
@@ -515,7 +499,6 @@ translations = {
'operation': "Működés", 'operation': "Működés",
'fan_mode': "Ventilátor", 'fan_mode': "Ventilátor",
'heating': "Fűtés", 'heating': "Fűtés",
'heat': "Fűtés",
}, },
'hy': { 'hy': {
'ACTIVATE': "Ակտիվացնել", 'ACTIVATE': "Ակտիվացնել",
@@ -543,7 +526,6 @@ translations = {
'operation': "Գործողություն", 'operation': "Գործողություն",
'fan_mode': "Երկրպագուների ռեժիմ", 'fan_mode': "Երկրպագուների ռեժիմ",
'heating': "Տաքացում", 'heating': "Տաքացում",
'heat': "Տաքացում",
}, },
'id': { 'id': {
'PRESS': "Tekan", 'PRESS': "Tekan",
@@ -574,7 +556,6 @@ translations = {
'operation': "Operasi", 'operation': "Operasi",
'fan_mode': "Mode kipas", 'fan_mode': "Mode kipas",
'heating': "Memanaskan", 'heating': "Memanaskan",
'heat': "Memanaskan",
}, },
'is': { 'is': {
'PRESS': "Ýttu á", 'PRESS': "Ýttu á",
@@ -604,7 +585,6 @@ translations = {
'operation': "Aðgerð", 'operation': "Aðgerð",
'fan_mode': "Viftuhamur", 'fan_mode': "Viftuhamur",
'heating': "Kynding", 'heating': "Kynding",
'heat': "Kynding",
}, },
'it': { 'it': {
'PRESS': "Premi", 'PRESS': "Premi",
@@ -635,7 +615,6 @@ translations = {
'operation': "Operazione", 'operation': "Operazione",
'fan_mode': "Ventilazione", 'fan_mode': "Ventilazione",
'heating': "Riscaldamento", 'heating': "Riscaldamento",
'heat': "Riscaldamento",
}, },
'lb': { 'lb': {
'ACTIVATE': "Aktivéieren", 'ACTIVATE': "Aktivéieren",
@@ -664,7 +643,6 @@ translations = {
'operation': "Aktioun", 'operation': "Aktioun",
'fan_mode': "Ventilatioun Modus", 'fan_mode': "Ventilatioun Modus",
'heating': "Hëtzen", 'heating': "Hëtzen",
'heat': "Hëtzen",
}, },
'lt': { 'lt': {
'ACTIVATE': "Suaktyvinti", 'ACTIVATE': "Suaktyvinti",
@@ -692,7 +670,6 @@ translations = {
'operation': "Operacija", 'operation': "Operacija",
'fan_mode': "Ventiliatoriaus režimas", 'fan_mode': "Ventiliatoriaus režimas",
'heating': "Šildymas", 'heating': "Šildymas",
'heat': "Šildymas",
}, },
'lv': { 'lv': {
'ACTIVATE': "Aktivizēt", 'ACTIVATE': "Aktivizēt",
@@ -720,7 +697,6 @@ translations = {
'operation': "Darbība", 'operation': "Darbība",
'fan_mode': "Ventilatora režīms", 'fan_mode': "Ventilatora režīms",
'heating': "Sildīšana", 'heating': "Sildīšana",
'heat': "Sildīšana",
}, },
'nb': { 'nb': {
'PRESS': "trykk", 'PRESS': "trykk",
@@ -751,7 +727,6 @@ translations = {
'operation': "Operasjon", 'operation': "Operasjon",
'fan_mode': "Viftemodus", 'fan_mode': "Viftemodus",
'heating': "Oppvarming", 'heating': "Oppvarming",
'heat': "Oppvarming",
}, },
'nl': { 'nl': {
'PRESS': "Klik", 'PRESS': "Klik",
@@ -782,7 +757,6 @@ translations = {
'operation': "Werking", 'operation': "Werking",
'fan_mode': "Ventilatormodus", 'fan_mode': "Ventilatormodus",
'heating': "Verwarmen", 'heating': "Verwarmen",
'heat': "Verwarmen",
}, },
'nn': { 'nn': {
'ACTIVATE': "Aktiver", 'ACTIVATE': "Aktiver",
@@ -812,7 +786,6 @@ translations = {
'operation': "Operasjon", 'operation': "Operasjon",
'fan_mode': "Viftemodus", 'fan_mode': "Viftemodus",
'heating': "Oppvarming", 'heating': "Oppvarming",
'heat': "Oppvarming",
}, },
'pl': { 'pl': {
'PRESS': "Naciśnij", 'PRESS': "Naciśnij",
@@ -843,7 +816,6 @@ translations = {
'operation': "Tryb pracy", 'operation': "Tryb pracy",
'fan_mode': "Tryb nawiewu", 'fan_mode': "Tryb nawiewu",
'heating': "grzanie", 'heating': "grzanie",
'heat': "grzanie",
}, },
'pt': { 'pt': {
'PRESS': "Pressione", 'PRESS': "Pressione",
@@ -873,7 +845,6 @@ translations = {
'operation': "Operação", 'operation': "Operação",
'fan_mode': "Modo ventilar", 'fan_mode': "Modo ventilar",
'heating': "Aquecimento", 'heating': "Aquecimento",
'heat': "Aquecimento",
}, },
'ro': { 'ro': {
'ACTIVATE': "Activați", 'ACTIVATE': "Activați",
@@ -903,7 +874,6 @@ translations = {
'operation': "Operație", 'operation': "Operație",
'fan_mode': "Mod ventilator", 'fan_mode': "Mod ventilator",
'heating': "Încălzește", 'heating': "Încălzește",
'heat': "Încălzește",
}, },
'ru': { 'ru': {
'PRESS': "Нажать", 'PRESS': "Нажать",
@@ -934,7 +904,6 @@ translations = {
'operation': "Режим работы", 'operation': "Режим работы",
'fan_mode': "Режим вентиляции", 'fan_mode': "Режим вентиляции",
'heating': "Обогрев", 'heating': "Обогрев",
'heat': "Обогрев",
}, },
'sk': { 'sk': {
'ACTIVATE': "Aktivovať", 'ACTIVATE': "Aktivovať",
@@ -964,7 +933,6 @@ translations = {
'operation': "Prevádzka", 'operation': "Prevádzka",
'fan_mode': "Režim ventilátora", 'fan_mode': "Režim ventilátora",
'heating': "Kúrenie", 'heating': "Kúrenie",
'heat': "Kúrenie",
}, },
'sl': { 'sl': {
'PRESS': "Pritisnite", 'PRESS': "Pritisnite",
@@ -994,7 +962,6 @@ translations = {
'operation': "Delovanje", 'operation': "Delovanje",
'fan_mode': "Način ventilatorja", 'fan_mode': "Način ventilatorja",
'heating': "Ogrevanje", 'heating': "Ogrevanje",
'heat': "Ogrevanje",
}, },
'sv': { 'sv': {
'PRESS': "Tryck", 'PRESS': "Tryck",
@@ -1025,7 +992,6 @@ translations = {
'operation': "Driftläge", 'operation': "Driftläge",
'fan_mode': "Fläktläge", 'fan_mode': "Fläktläge",
'heating': "Värmer", 'heating': "Värmer",
'heat': "Värmer",
}, },
'th': { 'th': {
'PRESS': "กด", 'PRESS': "กด",
@@ -1054,7 +1020,6 @@ translations = {
'operation': "การทำงาน", 'operation': "การทำงาน",
'fan_mode': "โหมดของพัดลม", 'fan_mode': "โหมดของพัดลม",
'heating': "โหมดอบอุ่น", 'heating': "โหมดอบอุ่น",
'heat': "โหมดอบอุ่น",
}, },
'tr': { 'tr': {
'PRESS': "Basınız", 'PRESS': "Basınız",
@@ -1085,7 +1050,6 @@ translations = {
'operation': "İşlem", 'operation': "İşlem",
'fan_mode': "Fan modu", 'fan_mode': "Fan modu",
'heating': "Isıtma", 'heating': "Isıtma",
'heat': "Isıtma",
}, },
'uk': { 'uk': {
'PRESS': "Натисніть", 'PRESS': "Натисніть",
@@ -1115,7 +1079,6 @@ translations = {
'operation': "Режим", 'operation': "Режим",
'fan_mode': "Режим вентиляції", 'fan_mode': "Режим вентиляції",
'heating': "Нагрівання", 'heating': "Нагрівання",
'heat': "Нагрівання",
}, },
'vi': { 'vi': {
'ACTIVATE': "Kích hoạt", 'ACTIVATE': "Kích hoạt",
@@ -1144,15 +1107,21 @@ translations = {
'operation': "Chế độ hoạt động", 'operation': "Chế độ hoạt động",
'fan_mode': "Chế độ quạt", 'fan_mode': "Chế độ quạt",
'heating': "Làm ấm", 'heating': "Làm ấm",
'heat': "Làm ấm",
}, },
} }
def get_translation(locale, input): def lookup(locale, inputstr):
locale = locale.split("_")[0] locale = locale.split("_")[0]
en_fallback_res = translations.get("en").get(input, input) en_fallback_res = translations.get("en").get(inputstr, inputstr)
if locale in translations: if locale in translations:
return translations.get(locale).get(input, en_fallback_res) return translations.get(locale).get(inputstr, en_fallback_res)
else: else:
return en_fallback_res return en_fallback_res
def get_translation(locale, inputstr):
inputstr = inputstr.replace("heat", "heating").replace("dry", "drying").replace("cool", "cooling").replace("fan_only", "fan")
if inputstr == "heat_cool":
return f'{lookup(locale, "heating")}/{lookup(locale, "cooling")}}'
return lookup(locale, inputstr)

View File

@@ -281,7 +281,7 @@ class LuiPagesGen(object):
current_temp = get_attr_safe(entity, "current_temperature", "") current_temp = get_attr_safe(entity, "current_temperature", "")
dest_temp = int(get_attr_safe(entity, "temperature", 0)*10) dest_temp = int(get_attr_safe(entity, "temperature", 0)*10)
status = get_attr_safe(entity, "hvac_action", "") status = get_attr_safe(entity, "hvac_action", "")
state_value = f"{get_translation(self._locale,status)}\r\n({get_translation(self._locale,entity.state)})" state_value = f"{get_translation(self._locale, status)}\r\n({get_translation(self._locale, entity.state)})"
min_temp = int(get_attr_safe(entity, "min_temp", 0)*10) min_temp = int(get_attr_safe(entity, "min_temp", 0)*10)
max_temp = int(get_attr_safe(entity, "max_temp", 0)*10) max_temp = int(get_attr_safe(entity, "max_temp", 0)*10)
step_temp = int(get_attr_safe(entity, "target_temp_step", 0.5)*10) step_temp = int(get_attr_safe(entity, "target_temp_step", 0.5)*10)