"""UI texts from `config/texts.yaml`, validated at startup so a missing key fails fast instead of mid-dialog.""" from pathlib import Path import yaml from pydantic import BaseModel, ConfigDict class _Strict(BaseModel): model_config = ConfigDict(extra="forbid", frozen=True) class MenuTexts(_Strict): commit: str status: str logs: str alerts: str members: str back: str cancel: str placeholder: str class StartTexts(_Strict): welcome: str no_access: str invite_rejected: str class HelpTexts(_Strict): text: str class SectionTexts(_Strict): commit: str status: str logs: str alerts: str members: str cancelled: str class MembersTexts(_Strict): title: str line: str never: str invite: str revoke: str confirm: str confirm_yes: str confirm_no: str revoked: str not_revoked: str invite_caption: str class Texts(_Strict): menu: MenuTexts start: StartTexts help: HelpTexts section: SectionTexts members: MembersTexts def load_texts(config_dir: Path) -> Texts: with (config_dir / "texts.yaml").open(encoding="utf-8") as f: return Texts.model_validate(yaml.safe_load(f))