mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
1.5 KiB
1.5 KiB
Node Definition Translation Collection Script
Overview
The collect-i18n-node-defs.ts script automatically extracts translatable content from ComfyUI node definitions to generate structured JSON files for internationalization (i18n).
What It Does
- Uses Playwright to load ComfyUI frontend and fetch node definitions via the ComfyUI HTTP API
- Extracts data types, node categories, input/output names, and descriptions
- Discovers runtime widget labels by creating actual node instances
- Normalizes keys for i18n compatibility (replaces dots with underscores)
- Generates
src/locales/en/main.json(data types & categories) andsrc/locales/en/nodeDefs.json
How It Works
- Browser Setup: Uses Playwright to load ComfyUI frontend and access the HTTP API
- Data Collection: Fetches node definitions via API and filters out DevTools nodes
- Widget Discovery: Creates LiteGraph node instances to find runtime-generated widgets
- Output Generation: Writes structured translation files
Key Features
- Runtime Widget Detection: Captures dynamically created widgets not in static definitions
- Data Type Deduplication: Skips output names that already exist as data types
- Special Character Handling: Normalizes keys with dots for i18n compatibility
Usage
npm run collect:i18n:nodeDefs
Output Structure
- main.json: Updates
dataTypesandnodeCategoriessections - nodeDefs.json: Complete node translation structure with inputs, outputs, and metadata