Skip to content

feat: add i18n support with auto language detection for GUI#17

Closed
iamvicliu wants to merge 5 commits intoo1xhack:mainfrom
iamvicliu:feat/gui-chinese-localization
Closed

feat: add i18n support with auto language detection for GUI#17
iamvicliu wants to merge 5 commits intoo1xhack:mainfrom
iamvicliu:feat/gui-chinese-localization

Conversation

@iamvicliu
Copy link
Copy Markdown
Contributor

@iamvicliu iamvicliu commented Mar 23, 2026

Summary

  • Add client-side i18n system that auto-detects browser language via navigator.language
  • Chinese (zh-CN) browsers see Chinese UI; all others see English (default)
  • 117 translation keys covering all user-facing strings: titles, buttons, labels, tooltips, status/error messages, timezone presets, time format options
  • Python backend remains language-neutral — all translation logic is in the JavaScript layer

How language detection works

  1. On page load, JavaScript reads navigator.language (e.g. "zh-CN", "en-US", "ja")
  2. If it starts with "zh" → use Chinese translations; otherwise → use English (default)
  3. Three helper functions handle all translations:
    • t("key") — returns the localized string for a given key
    • tf("key", {param: value}) — returns a localized string with parameter substitution (e.g. tf("runningPid", {pid: 1234})"运行中 (pid 1234)")
    • tLabel(label) — translates timezone/time-format preset labels sent from the server (e.g. "China - Shanghai""中国 - 上海")
  4. HTML lang attribute and page <title> also update dynamically based on detected language

No server-side changes are needed — the backend always sends English labels, and the JS layer translates them on the client side if the browser language is Chinese.

Scope

  • 1 file changed: telegram_watch/gui.py — ~430 insertions, ~125 deletions
  • No logic changes to config handling, runner, or API endpoints

Test plan

  • All 20 GUI-related unit tests pass
  • Verified on live deployment — Chinese browser shows Chinese UI
  • JS syntax validated with node --check
  • Confirm no regressions in GUI functionality (save/reload config, runner controls, group/user management)
  • Verify English fallback by testing with a non-Chinese browser

🤖 Generated with Claude Code

iamvicliu and others added 2 commits March 23, 2026 16:27
Translate all user-facing text in the web GUI to Simplified Chinese,
including page titles, labels, buttons, tooltips, status messages,
validation errors, and timezone/time-format presets. Cache-busting
query strings added to static asset URLs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a client-side i18n system that automatically detects browser
language via navigator.language and switches between English and
Chinese (zh-CN). All 150+ user-facing strings are now translatable
through a centralized translation table in JavaScript, keeping the
Python backend language-neutral.

- English and Chinese translation tables with t()/tf() helper functions
- Timezone preset and time format unit label translation via tLabel()
- Dynamic HTML lang attribute and page title based on detected language
- All 20 GUI-related tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iamvicliu iamvicliu changed the title feat: add Chinese (zh-CN) localization for GUI feat: add i18n support with auto language detection for GUI Mar 23, 2026
iamvicliu and others added 3 commits March 23, 2026 17:16
Replace Chinese quotes "" with brackets 「」 to avoid breaking
the JavaScript string literal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A stray Unicode left/right double quotation mark (U+201C/U+201D)
broke the JavaScript template literal at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Append ?v=2 to app.js and app.css references in HTML to ensure
browsers load the updated i18n version instead of cached copies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@o1xhack
Copy link
Copy Markdown
Owner

o1xhack commented Mar 27, 2026

Merged into dev and included in v1.6.0 release PR #19

@o1xhack o1xhack closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants