feat v1.11.0: full English translation + en/ru UI localization

- All card UI strings moved to src/i18n.ts (en/ru); language follows the HA
  profile automatically, new 'language: en|ru' card option forces it; GUI
  editor localized and got the language dropdown; generated device names
  localized via BuildCtx.loc.
- English-only codebase: comments, docstrings, test names, backend error
  messages and logs. Russian remains only in the ru dictionary, ru.json,
  iconFor regexes matching Russian device names (+their fixtures) and README.ru.md.
- Docs English-first: README (EN) + README.ru.md, ARCHITECTURE/DEVELOPMENT/
  ROADMAP/CHANGELOG fully translated; translations/en.json had Russian - fixed.
- Removed obsolete RELEASE_NOTES_v1.9.3.md and scripts_publish.sh.
This commit is contained in:
Matysh
2026-07-05 21:43:58 +03:00
parent f1b372f0e6
commit 94fb4af14c
29 changed files with 1692 additions and 1210 deletions
+13 -13
View File
@@ -1,6 +1,6 @@
"""Чистая валидация и санитайзеры House Plan — без зависимостей от Home Assistant.
"""Pure House Plan validation and sanitizers — no Home Assistant dependencies.
Вынесено отдельно, чтобы покрывать юнит-тестами (нужен только voluptuous).
Kept separate so it can be covered by unit tests (only voluptuous is needed).
"""
from __future__ import annotations
@@ -8,7 +8,7 @@ import re
import voluptuous as vol
# ---------- лимиты и наборы расширений ----------
# ---------- limits and extension sets ----------
PLAN_EXTENSIONS = {"svg": "image/svg+xml", "png": "image/png", "jpg": "image/jpeg", "webp": "image/webp"}
MAX_PLAN_BYTES = 8 * 1024 * 1024
FILE_EXTENSIONS = {"pdf", "png", "jpg", "jpeg", "webp", "txt"}
@@ -17,27 +17,27 @@ MAX_FILE_BYTES = 25 * 1024 * 1024
SPACE_ID_RE = re.compile(r"^[a-z0-9_-]{1,64}$")
_SAFE_NAME_RE = re.compile(r"[^A-Za-z0-9._-]+")
# ---------- санитайзеры ----------
# ---------- sanitizers ----------
def sanitize_marker_id(value: str) -> str:
"""Безопасный идентификатор маркера для имени папки.
"""Safe marker identifier for a folder name.
Убирает разделители путей и ведущие точки, чтобы исключить обход каталогов
(напр. '..', '../x'); пустой/из одних точек результат'misc'.
Strips path separators and leading dots to rule out directory traversal
(e.g. '..', '../x'); an empty/dots-only result'misc'.
"""
cleaned = _SAFE_NAME_RE.sub("_", value).lstrip(".")[:64]
return cleaned or "misc"
def sanitize_filename(value: str) -> str:
"""Отбросить путь и ведущие точки, оставить безопасное имя файла."""
"""Drop the path and leading dots, keep a safe file name."""
raw = value.rsplit("/", 1)[-1].rsplit("\\", 1)[-1]
return _SAFE_NAME_RE.sub("_", raw).lstrip(".")[:120] or "file"
def file_ext(filename: str) -> str:
"""Расширение файла в нижнем регистре ('' если нет)."""
"""Lowercase file extension ('' if none)."""
raw = filename.rsplit("/", 1)[-1].rsplit("\\", 1)[-1]
return raw.rsplit(".", 1)[-1].lower() if "." in raw else ""
@@ -46,10 +46,10 @@ def valid_space_id(value: str) -> bool:
return bool(SPACE_ID_RE.match(value))
# ---------- voluptuous-схемы ----------
# ---------- voluptuous schemas ----------
POS_SCHEMA = vol.Schema(
{vol.Required("x"): vol.Coerce(float), vol.Required("y"): vol.Coerce(float)},
extra=vol.ALLOW_EXTRA, # v2-записи несут ключ "s" (space id)
extra=vol.ALLOW_EXTRA, # v2 records carry the "s" key (space id)
)
LAYOUT_SCHEMA = vol.Schema({str: POS_SCHEMA})
@@ -59,7 +59,7 @@ POINT = vol.All([vol.Coerce(float)], vol.Length(min=2, max=2))
def _require_geometry(room: dict) -> dict:
if "poly" in room or all(k in room for k in ("x", "y", "w", "h")):
return room
raise vol.Invalid("room: нужен poly или x/y/w/h")
raise vol.Invalid("room: poly or x/y/w/h is required")
ROOM_SCHEMA = vol.All(
@@ -115,5 +115,5 @@ CONFIG_SCHEMA = vol.Schema(
vol.Optional("markers", default=list): [MARKER_SCHEMA],
vol.Optional("settings", default=dict): vol.Schema({}, extra=vol.ALLOW_EXTRA),
},
extra=vol.ALLOW_EXTRA, # неизвестные ключи (легаси) не ломают загрузку
extra=vol.ALLOW_EXTRA, # unknown (legacy) keys do not break loading
)