Skip to content

Commit b0ebf45

Browse files
committed
fix: i18n.py hard code and debugging on the setting ui
1 parent ba91135 commit b0ebf45

File tree

3 files changed

+88
-11
lines changed

3 files changed

+88
-11
lines changed

i18n.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,28 @@
55

66
from typing import Dict, Optional
77

8-
# Current language setting
9-
_current_language = "zh_TW"
8+
# ═══════════════════════════════════════════════════════════════════════════
9+
# CRITICAL: Default Language Configuration
10+
# ═══════════════════════════════════════════════════════════════════════════
11+
# ⚠️ WARNING: DO NOT change this default to any language other than "en"
12+
#
13+
# This is the FALLBACK language used when:
14+
# 1. ComfyUI first loads (before user settings are applied)
15+
# 2. The frontend hasn't called /debugger/set_language yet
16+
# 3. Automatic error pattern matching (non-AI suggestions)
17+
#
18+
# WHY "en" (NOT "zh_TW" or other languages):
19+
# - International users expect English as the default
20+
# - Prevents confusion when users haven't configured language yet
21+
# - Matches frontend DEFAULTS.LANGUAGE in web/doctor.js
22+
#
23+
# If you want to change the default language for YOUR installation:
24+
# → Update the user's ComfyUI settings (Doctor.General.Language)
25+
# → DO NOT modify this hardcoded value
26+
#
27+
# Last Modified: 2026-01-03 (Fixed from "zh_TW" to "en")
28+
# ═══════════════════════════════════════════════════════════════════════════
29+
_current_language = "en"
1030

1131
# Supported languages
1232
SUPPORTED_LANGUAGES = ["en", "zh_TW", "zh_CN", "ja", "de", "fr", "it", "es", "ko"]

web/doctor.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,30 @@ import { api } from "../../../scripts/api.js";
77
import { DoctorUI } from "./doctor_ui.js";
88
import { DoctorAPI } from "./doctor_api.js";
99

10-
// Default values
10+
// ═══════════════════════════════════════════════════════════════════════════
11+
// CRITICAL: Frontend Default Configuration
12+
// ═══════════════════════════════════════════════════════════════════════════
13+
// ⚠️ WARNING: LANGUAGE must always be "en" (English)
14+
//
15+
// This default is used when:
16+
// 1. User first installs ComfyUI-Doctor (no settings saved yet)
17+
// 2. ComfyUI settings are reset/corrupted
18+
// 3. DoctorUI constructor receives no language option
19+
//
20+
// MUST MATCH backend default in i18n.py (_current_language = "en")
21+
//
22+
// If these don't match:
23+
// ❌ Backend suggestions will be in different language than UI
24+
// ❌ Confusing experience for international users
25+
//
26+
// To change default for your installation:
27+
// → Modify ComfyUI Settings → Doctor → Language
28+
// → DO NOT change this hardcoded value
29+
//
30+
// Last Modified: 2026-01-03 (Fixed from "zh_TW" to "en")
31+
// ═══════════════════════════════════════════════════════════════════════════
1132
const DEFAULTS = {
12-
LANGUAGE: "zh_TW",
33+
LANGUAGE: "en", // ⚠️ DO NOT CHANGE - Must match i18n.py backend default
1334
POLL_INTERVAL: 2000,
1435
AUTO_OPEN_ON_ERROR: false,
1536
ENABLE_NOTIFICATIONS: true,

web/doctor_ui.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ import { ChatPanel } from "./doctor_chat.js";
3333
*/
3434
export class DoctorUI {
3535
constructor(options = {}) {
36-
// Configuration from ComfyUI settings
37-
this.language = options.language || 'zh_TW';
36+
// ═══════════════════════════════════════════════════════════════
37+
// CRITICAL: Language Fallback Configuration
38+
// ═══════════════════════════════════════════════════════════════
39+
// ⚠️ WARNING: Fallback must be 'en' (NOT 'zh_TW' or other languages)
40+
//
41+
// This fallback is used when options.language is undefined/null
42+
// MUST MATCH:
43+
// - Backend: i18n.py (_current_language = "en")
44+
// - Frontend: doctor.js (DEFAULTS.LANGUAGE = "en")
45+
//
46+
// Last Modified: 2026-01-03 (Fixed from 'zh_TW' to 'en')
47+
// ═══════════════════════════════════════════════════════════════
48+
this.language = options.language || 'en'; // ⚠️ DO NOT CHANGE fallback
3849
this.pollInterval = options.pollInterval || 2000;
3950
this.autoOpenOnError = options.autoOpenOnError || false;
4051
this.enableNotifications = options.enableNotifications || true;
@@ -49,16 +60,41 @@ export class DoctorUI {
4960
this.lastErrorTimestamp = 0;
5061
this.ERROR_DEBOUNCE_MS = 1000; // Ignore duplicate errors within 1 second
5162

52-
// UI text translations
53-
// IMPORTANT: this.uiText starts as empty object {}
54-
// loadUIText() is ASYNC and will populate it later
63+
// ═══════════════════════════════════════════════════════════════
64+
// CRITICAL: UI Text Loading Order
65+
// ═══════════════════════════════════════════════════════════════
66+
// ⚠️ WARNING: this.uiText MUST be loaded BEFORE createSidebar()
67+
//
68+
// Common Bug Pattern (INCORRECT):
69+
// this.uiText = {};
70+
// this.loadUIText(); // ❌ Async, doesn't wait
71+
// this.createSidebar(); // ❌ Creates UI before translations load
72+
// Result: All UI text shows "[Missing: key_name]"
73+
//
74+
// Correct Pattern (CURRENT):
75+
// this.uiText = {};
76+
// this.loadUIText().then(() => { // ✅ Wait for translations
77+
// this.createSidebar(); // ✅ Create UI after load
78+
// });
79+
//
80+
// Why This Matters:
81+
// - Sidebar uses getUIText() extensively (save_settings_btn, etc.)
82+
// - If uiText is empty {}, getUIText() returns "[Missing: ...]"
83+
// - Users see broken UI with missing translations
84+
//
85+
// Last Modified: 2026-01-03 (Fixed race condition)
86+
// ═══════════════════════════════════════════════════════════════
5587
this.uiText = {};
56-
this.loadUIText();
5788

5889
this.createStyles();
59-
this.createSidebar();
6090
this.createMenuButton();
6191

92+
// ⚠️ CRITICAL: Load UI text FIRST, then create sidebar
93+
// DO NOT move createSidebar() before loadUIText() completes!
94+
this.loadUIText().then(() => {
95+
this.createSidebar();
96+
});
97+
6298
// Subscribe to ComfyUI execution_error events (instant, more accurate)
6399
this.subscribeToExecutionErrors();
64100

0 commit comments

Comments
 (0)