|
| 1 | +# Contributing Translations to ComfyUI |
| 2 | + |
| 3 | +## Quick Start for New Languages |
| 4 | + |
| 5 | +1. **Let us know** - Open an issue or reach out on Discord to request a new language |
| 6 | +2. **Get technical setup help** - We'll help configure the initial files or you can follow the technical process below |
| 7 | +3. **Automatic translation** - Our CI system will generate translations using OpenAI when you create a PR |
| 8 | +4. **Review and refine** - You can improve the auto-generated translations and become a maintainer for that language |
| 9 | + |
| 10 | +## Technical Process (Confirmed Working) |
| 11 | + |
| 12 | +### Prerequisites |
| 13 | +- Node.js installed |
| 14 | +- Git/GitHub knowledge |
| 15 | +- OpenAI API key (optional - CI will handle translations) |
| 16 | + |
| 17 | +### Step 1: Update Configuration Files |
| 18 | + |
| 19 | +**Time required: ~10 minutes** |
| 20 | + |
| 21 | +#### 1.1 Update `.i18nrc.cjs` |
| 22 | +Add your language code to the `outputLocales` array: |
| 23 | + |
| 24 | +```javascript |
| 25 | +module.exports = defineConfig({ |
| 26 | + // ... existing config |
| 27 | + outputLocales: ['zh', 'zh-TW', 'ru', 'ja', 'ko', 'fr', 'es'], // Add your language here |
| 28 | + reference: `Special names to keep untranslated: flux, photomaker, clip, vae, cfg, stable audio, stable cascade, stable zero, controlnet, lora, HiDream. |
| 29 | + 'latent' is the short form of 'latent space'. |
| 30 | + 'mask' is in the context of image processing. |
| 31 | + Note: For Traditional Chinese (Taiwan), use Taiwan-specific terminology and traditional characters. |
| 32 | + ` |
| 33 | +}); |
| 34 | +``` |
| 35 | + |
| 36 | +#### 1.2 Update `src/constants/coreSettings.ts` |
| 37 | +Add your language to the dropdown options: |
| 38 | + |
| 39 | +```typescript |
| 40 | +{ |
| 41 | + id: 'Comfy.Locale', |
| 42 | + name: 'Language', |
| 43 | + type: 'combo', |
| 44 | + options: [ |
| 45 | + { value: 'en', text: 'English' }, |
| 46 | + { value: 'zh', text: '中文' }, |
| 47 | + { value: 'zh-TW', text: '繁體中文 (台灣)' }, // Add your language here |
| 48 | + { value: 'ru', text: 'Русский' }, |
| 49 | + { value: 'ja', text: '日本語' }, |
| 50 | + { value: 'ko', text: '한국어' }, |
| 51 | + { value: 'fr', text: 'Français' }, |
| 52 | + { value: 'es', text: 'Español' } |
| 53 | + ], |
| 54 | + defaultValue: () => navigator.language.split('-')[0] || 'en' |
| 55 | +}, |
| 56 | +``` |
| 57 | + |
| 58 | +#### 1.3 Update `src/i18n.ts` |
| 59 | +Add imports for your new language files: |
| 60 | + |
| 61 | +```typescript |
| 62 | +// Add these imports (replace zh-TW with your language code) |
| 63 | +import zhTWCommands from './locales/zh-TW/commands.json' |
| 64 | +import zhTW from './locales/zh-TW/main.json' |
| 65 | +import zhTWNodes from './locales/zh-TW/nodeDefs.json' |
| 66 | +import zhTWSettings from './locales/zh-TW/settings.json' |
| 67 | + |
| 68 | +// Add to the messages object |
| 69 | +const messages = { |
| 70 | + en: buildLocale(en, enNodes, enCommands, enSettings), |
| 71 | + zh: buildLocale(zh, zhNodes, zhCommands, zhSettings), |
| 72 | + 'zh-TW': buildLocale(zhTW, zhTWNodes, zhTWCommands, zhTWSettings), // Add this line |
| 73 | + // ... other languages |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### Step 2: Generate Translation Files |
| 78 | + |
| 79 | +#### Option A: Local Generation (Optional) |
| 80 | +```bash |
| 81 | +# Only if you have OpenAI API key configured |
| 82 | +npm run locale |
| 83 | +``` |
| 84 | + |
| 85 | +#### Option B: Let CI Handle It (Recommended) |
| 86 | +- Create your PR with the configuration changes above |
| 87 | +- Our GitHub CI will automatically generate translation files |
| 88 | +- Empty JSON files are fine - they'll be populated by the workflow |
| 89 | + |
| 90 | +### Step 3: Test Your Changes |
| 91 | + |
| 92 | +```bash |
| 93 | +npm run typecheck # Check for TypeScript errors |
| 94 | +npm run dev # Start development server |
| 95 | +``` |
| 96 | + |
| 97 | +**Testing checklist:** |
| 98 | +- [ ] Language appears in ComfyUI Settings > Locale dropdown |
| 99 | +- [ ] Can select the new language without errors |
| 100 | +- [ ] Partial translations display correctly |
| 101 | +- [ ] UI falls back to English for untranslated strings |
| 102 | +- [ ] No console errors when switching languages |
| 103 | + |
| 104 | +### Step 4: Submit PR |
| 105 | + |
| 106 | +1. **Create PR** with your configuration changes |
| 107 | +2. **CI will run** and automatically populate translation files |
| 108 | +3. **Request review** from language maintainers: @Yorha4D @KarryCharon @DorotaLuna @shinshin86 |
| 109 | +4. **Get added to CODEOWNERS** as a reviewer for your language |
| 110 | + |
| 111 | +## What Happens in CI |
| 112 | + |
| 113 | +Our automated translation workflow: |
| 114 | +1. **Collects strings**: Scans the UI for translatable text |
| 115 | +2. **Updates English files**: Ensures all strings are captured |
| 116 | +3. **Generates translations**: Uses OpenAI API to translate to all configured languages |
| 117 | +4. **Commits back**: Automatically updates your PR with complete translations |
| 118 | + |
| 119 | +## File Structure |
| 120 | + |
| 121 | +Each language has 4 translation files: |
| 122 | +- `main.json` - Main UI text (~2000+ entries) |
| 123 | +- `commands.json` - Command descriptions (~200+ entries) |
| 124 | +- `settings.json` - Settings panel (~400+ entries) |
| 125 | +- `nodeDefs.json` - Node definitions (~varies based on installed nodes) |
| 126 | + |
| 127 | +## Translation Quality |
| 128 | + |
| 129 | +- **Auto-translations are high quality** but may need refinement |
| 130 | +- **Technical terms** are preserved (flux, photomaker, clip, vae, etc.) |
| 131 | +- **Context-aware** translations based on UI usage |
| 132 | +- **Native speaker review** is encouraged for quality improvements |
| 133 | + |
| 134 | +## Common Issues & Solutions |
| 135 | + |
| 136 | +### Issue: TypeScript errors on imports |
| 137 | +**Solution**: Ensure your language code matches exactly in all three files |
| 138 | + |
| 139 | +### Issue: Empty translation files |
| 140 | +**Solution**: This is normal - CI will populate them when you create a PR |
| 141 | + |
| 142 | +### Issue: Language not appearing in dropdown |
| 143 | +**Solution**: Check that the language code in `coreSettings.ts` matches your other files exactly |
| 144 | + |
| 145 | +### Issue: Rate limits during local translation |
| 146 | +**Solution**: This is expected - let CI handle the translation generation |
| 147 | + |
| 148 | +## Regional Variants |
| 149 | + |
| 150 | +For regional variants (like zh-TW for Taiwan), use: |
| 151 | +- **Language-region codes**: `zh-TW`, `pt-BR`, `en-US` |
| 152 | +- **Specific terminology**: Add region-specific context to the reference string |
| 153 | +- **Native display names**: Use the local language name in the dropdown |
| 154 | + |
| 155 | +## Getting Help |
| 156 | + |
| 157 | +- **Tag translation maintainers**: @Yorha4D @KarryCharon @DorotaLuna @shinshin86 |
| 158 | +- **Check existing language PRs** for examples |
| 159 | +- **Open an issue** describing your language addition request |
| 160 | +- **Reference this tested process** - we've confirmed it works! |
| 161 | + |
| 162 | +## Becoming a Language Maintainer |
| 163 | + |
| 164 | +After your language is added: |
| 165 | +1. **Get added to CODEOWNERS** for your language files |
| 166 | +2. **Review future PRs** affecting your language |
| 167 | +3. **Coordinate with other native speakers** for quality improvements |
| 168 | +4. **Help maintain translations** as the UI evolves |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +*This process was tested and confirmed working with Traditional Chinese (Taiwan) addition.* |
0 commit comments