feat(i18n): translate starter template note/README nodes at serve-time

- Extend extract_backend_strings.py to extract noteNode descriptions as
  template_notes.{flow_key}.{index} keys (64 notes across 32 templates)
- Add translate_flow_notes() to i18n.py to substitute translated markdown
  per-request without mutating the cached template data
- Wire translate_flow_notes() into the /starter-projects/ endpoint using
  the same request.state.locale pattern as the flows endpoint
- Update all 6 backend locale files via GP pipeline (4858 keys total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
RamGopalSrikar
2026-04-13 20:46:39 -04:00
parent 1e94ebedb1
commit 4bbe1b3d48
10 changed files with 513 additions and 10 deletions

View File

@ -119,6 +119,30 @@ def collect_strings() -> dict[str, str]:
print(f"Found {starter_count} starter project(s) in {STARTER_PROJECTS_DIR.name}/")
# Tier 4 — note node descriptions in starter projects
note_count = 0
for project_file in sorted(STARTER_PROJECTS_DIR.glob("*.json")):
try:
with project_file.open(encoding="utf-8") as f:
project = json.load(f)
except Exception: # noqa: BLE001
continue
name = project.get("name")
if not name or not isinstance(name, str):
continue
flow_key = _safe_key(name)
nodes = project.get("data", {}).get("nodes", [])
note_index = 0
for node in nodes:
if node.get("type") == "noteNode":
description = node.get("data", {}).get("node", {}).get("description", "")
if description and isinstance(description, str):
flat[f"template_notes.{flow_key}.{note_index}"] = description
note_count += 1
note_index += 1
print(f"Found {note_count} note node(s) across starter projects.")
return dict(sorted(flat.items()))