Skip to content

Replace UI text with Chinese (zh) translation#5671

Draft
foxlesbiao wants to merge 2 commits into
wled:mainfrom
foxlesbiao:chinese-translation
Draft

Replace UI text with Chinese (zh) translation#5671
foxlesbiao wants to merge 2 commits into
wled:mainfrom
foxlesbiao:chinese-translation

Conversation

@foxlesbiao
Copy link
Copy Markdown

@foxlesbiao foxlesbiao commented Jun 5, 2026

Description

Complete Chinese (Simplified) translation of all 22 WLED Web UI HTML files.

Changes

  • Translated all visible UI text: titles, buttons, labels, form fields, tooltips, error messages, status messages, context menus
  • Changed lang="en" to lang="zh" in all files
  • Preserved all HTML structure, JavaScript code/logic, CSS, variable names, element IDs, URLs, and onclick handlers unchanged

Translated Files (22 total)

File Description
404.htm 404 error page
dmxmap.htm DMX channel mapping
edit.htm File editor
index.htm Main UI
liveview.htm Live preview
liveviewws2D.htm 2D live preview
msg.htm Message page
settings.htm Settings hub
settings_2D.htm 2D configuration
settings_dmx.htm DMX output settings
settings_leds.htm LED & hardware settings
settings_pin.htm Pin configuration
settings_pininfo.htm Pin information
settings_sec.htm Security & updates
settings_sync.htm Sync interfaces
settings_time.htm Time & macros
settings_ui.htm UI settings
settings_um.htm Usermods settings
settings_wifi.htm WiFi & network
update.htm OTA update
usermod.htm Usermod page
welcome.htm Welcome/setup page

Summary by CodeRabbit

  • New Features
    • Complete Chinese localization of the web UI: main app, live preview, editor, settings (all subpages), DMX/2D/LED/Update/Sync/time panels, toasts/alerts, modals and navigation — all user-facing labels, buttons, messages and placeholders are translated to Chinese, preserving existing behavior and layout.

已翻译文件:
- 404.htm, dmxmap.htm, edit.htm, index.htm
- liveview.htm, liveviewws2D.htm, msg.htm
- settings.htm, settings_2D.htm, settings_dmx.htm
- settings_leds.htm, settings_pin.htm, settings_pininfo.htm
- settings_sec.htm, settings_sync.htm, settings_time.htm
- settings_ui.htm, settings_um.htm, settings_wifi.htm
- update.htm, usermod.htm, welcome.htm

翻译内容:标题、按钮、标签、提示文字、错误信息
保持不变:HTML结构、JS代码、CSS、变量名、URL
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

Walkthrough

All web UI files under wled00/data/ were localized from English to Chinese: each page’s root lang attribute is set to zh and visible user-facing text (titles, labels, placeholders, toasts, buttons, option lists) was translated, preserving HTML structure, IDs, and JavaScript logic.

Changes

Complete Web UI Chinese Localization

Layer / File(s) Summary
Utility & simple pages
wled00/data/404.htm, wled00/data/dmxmap.htm, wled00/data/msg.htm, wled00/data/welcome.htm, wled00/data/usermod.htm, wled00/data/liveview.htm, wled00/data/liveviewws2D.htm, wled00/data/edit.htm
Document lang attributes and page titles plus simple page body text and basic UI strings were translated to Chinese; structural markup and event handlers remain unchanged.
File editor UI strings
wled00/data/edit.htm
Top-bar buttons, upload-success toast, delete confirmation, context-menu labels, validation alerts, and filename placeholder were localized to Chinese while preserving upload/save/delete wiring.
Main control interface
wled00/data/index.htm
Primary dashboard localized: loading overlay, top navigation, color controls (H/S/V, Kelvin, RGB, white), palettes, effects (search/filters/sliders), segments/presets, footer and modals translated to Chinese; element IDs and handlers preserved.
Settings hub and core pages
wled00/data/settings.htm, wled00/data/settings_ui.htm, wled00/data/settings_sec.htm, wled00/data/settings_pin.htm, wled00/data/settings_pininfo.htm
Settings navigation, UI label dictionary, JSON/localStorage messages, security/update controls, PIN auth UI, and pin-info rendering text translated to Chinese, keeping form names, IDs, and routing intact.
LED settings & 2D matrix
wled00/data/settings_leds.htm, wled00/data/settings_2D.htm
LED hardware UI (per-bus labels, per-output controls, COM entries, button types) and 2D panel/matrix editor strings localized to Chinese; generation logic and field IDs unchanged.
DMX settings & mapping
wled00/data/dmxmap.htm, wled00/data/settings_dmx.htm
DMX page title, dmxlabels entries, per-channel <option> labels, and DMX output form strings translated to Chinese without changing input names or form wiring.
Network, WiFi and sync settings
wled00/data/settings_wifi.htm, wled00/data/settings_sync.htm
WiFi scan/status, addWiFi template, Ethernet/DNS/AP options, TX-power, ESP-NOW, and sync/MQTT/Hue/Serial section labels were localized to Chinese while preserving underlying form structure.
Time, usermod and update tools
wled00/data/settings_time.htm, wled00/data/settings_um.htm, wled00/data/update.htm
Timer UI, month names, presets/macro labels, usermod status messages, and auto-update status/controls were translated to Chinese while keeping JavaScript behavior and callbacks unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wled/WLED#5356: Both PRs modify wled00/data/welcome.htm user-facing text.
  • wled/WLED#5419: Overlaps on wled00/data/update.htm (update UI and auto-update logic).
  • wled/WLED#5381: Related changes to root HTML lang attributes across UI pages.

Suggested labels

good job

Suggested reviewers

  • softhack007
  • DedeHai
  • netmindz
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'Replace UI text with Chinese (zh) translation' accurately summarizes the main change: localizing all 22 Web UI HTML files to Chinese.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
wled00/data/settings_leds.htm (1)

2-2: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update document language metadata to Chinese.

Line 2 is still lang="en" while the page content is localized to Chinese; switch to lang="zh" to keep accessibility and language detection correct.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wled00/data/settings_leds.htm` at line 2, The page's HTML root element still
declares lang="en" while the content is Chinese; update the <html> element in
settings_leds.htm from lang="en" to lang="zh" (or a more specific variant like
lang="zh-CN" if appropriate) so language metadata matches the localized content
and aids accessibility and language detection.
wled00/data/update.htm (1)

99-101: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Localize auto-update “firmware not found” status

When no matching asset is found, the status message is still English (Firmware not found... Available...). This is user-visible in the Chinese workflow and should be translated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wled00/data/update.htm` around lines 99 - 101, The status message shown when
no matching asset is found uses hardcoded English in the assignment to
status.textContent (currently using `Firmware not found (*${assetSuffix}).
Available: ${available}`); replace that literal with the localized string lookup
used elsewhere (e.g., call the project's i18n function or lookup table) and
format it with assetSuffix and available, so the message is translated for other
locales; ensure you still set btn.disabled = false and keep the `available` and
`assetSuffix` variables in the formatted localized message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wled00/data/settings_dmx.htm`:
- Line 58: The label text contains an English word "Universe" breaking
localization; update the string in the settings_dmx.htm line that renders "代理
Universe <input name=PU ..." (input name=PU) to a fully localized Chinese term
(e.g., "代理 宇宙 <input name=PU ...> 从 E1.31 到 DMX(0=禁用)") so the UI is consistent.

In `@wled00/data/settings_sec.htm`:
- Line 50: The tooltip for the PIN input is in English; update the input element
with id="PIN" (the PIN <input> element) to use a Chinese title string instead of
"Please enter a 4 digit number" so it matches the localized page (e.g. "请输入4位数字"
or similar), keeping the other attributes (type, id, name, size, maxlength,
minlength, onkeydown, pattern, inputmode) unchanged.
- Line 77: Replace the literal English "Upload" button labels with the Chinese
localized text by changing the button text nodes for the buttons that call
uploadFile (the <button ... onclick="uploadFile(...)"> elements) to "上传" (or the
project's Chinese localization token if one exists); update both occurrences
noted (the buttons near the file input for presets and the other at line 79) and
keep the onclick/uploadFile calls and attributes unchanged so functionality is
preserved.

In `@wled00/data/settings_sync.htm`:
- Line 218: The label text containing the English word "presets" should be
localized; locate the HTML snippet containing the input element with name="AP"
and replace the trailing English word "presets" with the Chinese localized term
(e.g., "预设") so the line reads consistently in Chinese and preserves the
existing input markup.

In `@wled00/data/settings_wifi.htm`:
- Line 263: The AP password input element (name="AP", pattern="(.{8,63})|()")
currently uses an English title "Empty or min. 8 characters"; update that title
to the Chinese translation so the validation hint is localized (e.g.
"为空或至少8个字符") while leaving the pattern and maxlength unchanged.
- Around line 126-130: The encryption option labels in the template string
assigned to encryptionTypeField are still in English; update the displayed
option text for option elements (the ones rendered for id/name "ET${i}") to use
localized strings or bilingual wording consistent with the page (e.g., replace
"None/WPA/WPA2" and "WPA/WPA2-Enterprise" with localized equivalents or add the
translated text alongside the English text). Ensure the change updates the
template that builds the select for ET${i} so the selected logic ((type==0) /
(type==1)) remains intact and onchange="E(${i})" continues to work.

In `@wled00/data/update.htm`:
- Around line 136-139: The placeholders "Loading..." and "Checking..." are still
in English; update the HTML in update.htm to use Chinese localized text (e.g.,
"加载中..." for class="sip installed-version" and class="sip release-name", and
"检查中..." for the span with id="Norelease-download") so the UI is consistent;
adjust the content for the span id="release-download" if it contains any English
placeholder text as well and ensure all three referenced elements ("sip
installed-version", "sip release-name", "Norelease-download", and
"release-download") display the Chinese strings.

---

Outside diff comments:
In `@wled00/data/settings_leds.htm`:
- Line 2: The page's HTML root element still declares lang="en" while the
content is Chinese; update the <html> element in settings_leds.htm from
lang="en" to lang="zh" (or a more specific variant like lang="zh-CN" if
appropriate) so language metadata matches the localized content and aids
accessibility and language detection.

In `@wled00/data/update.htm`:
- Around line 99-101: The status message shown when no matching asset is found
uses hardcoded English in the assignment to status.textContent (currently using
`Firmware not found (*${assetSuffix}). Available: ${available}`); replace that
literal with the localized string lookup used elsewhere (e.g., call the
project's i18n function or lookup table) and format it with assetSuffix and
available, so the message is translated for other locales; ensure you still set
btn.disabled = false and keep the `available` and `assetSuffix` variables in the
formatted localized message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 065507ad-8cc4-4391-974f-e6041ae4e794

📥 Commits

Reviewing files that changed from the base of the PR and between 3a50268 and 733fe56.

📒 Files selected for processing (22)
  • wled00/data/404.htm
  • wled00/data/dmxmap.htm
  • wled00/data/edit.htm
  • wled00/data/index.htm
  • wled00/data/liveview.htm
  • wled00/data/liveviewws2D.htm
  • wled00/data/msg.htm
  • wled00/data/settings.htm
  • wled00/data/settings_2D.htm
  • wled00/data/settings_dmx.htm
  • wled00/data/settings_leds.htm
  • wled00/data/settings_pin.htm
  • wled00/data/settings_pininfo.htm
  • wled00/data/settings_sec.htm
  • wled00/data/settings_sync.htm
  • wled00/data/settings_time.htm
  • wled00/data/settings_ui.htm
  • wled00/data/settings_um.htm
  • wled00/data/settings_wifi.htm
  • wled00/data/update.htm
  • wled00/data/usermod.htm
  • wled00/data/welcome.htm

Comment thread wled00/data/settings_dmx.htm Outdated
Proxy Universe <input name=PU type=number min=0 max=63999 required> from E1.31 to DMX (0=disabled)<br>
<i>This will disable the LED data output to DMX configurable below</i><br><br>
<i>Number of fixtures is taken from LED config page</i><br>
代理 Universe <input name=PU type=number min=0 max=63999 required> E1.31 DMX(0=禁用)<br>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Translate mixed-language label for consistency

Line 58 still contains Universe in English (代理 Universe ...), which breaks the otherwise fully localized UI on this page.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wled00/data/settings_dmx.htm` at line 58, The label text contains an English
word "Universe" breaking localization; update the string in the settings_dmx.htm
line that renders "代理 Universe <input name=PU ..." (input name=PU) to a fully
localized Chinese term (e.g., "代理 宇宙 <input name=PU ...> 从 E1.31 到 DMX(0=禁用)")
so the UI is consistent.

Comment thread wled00/data/settings_sec.htm Outdated
Comment thread wled00/data/settings_sec.htm Outdated
Comment thread wled00/data/settings_sync.htm Outdated
Comment thread wled00/data/settings_wifi.htm
Comment thread wled00/data/settings_wifi.htm Outdated
Comment thread wled00/data/update.htm Outdated
- settings_leds.htm: lang=en → lang=zh
- settings_dmx.htm: Universe 补冒号
- settings_sec.htm: PIN 提示、Upload 按钮翻译
- settings_sync.htm: presets → 个预设
- settings_wifi.htm: AP 密码提示、加密类型翻译
- update.htm: Loading/Checking/Firmware not found 翻译
@foxlesbiao
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@DedeHai
Copy link
Copy Markdown
Collaborator

DedeHai commented Jun 5, 2026

thanks, but it is not "add" but "replace with". There is currently no way for multi language support, this has been attempted several times already for other languages but simply replacing everything is not acceptable. You can keep this in your fork though.

@DedeHai DedeHai marked this pull request as draft June 5, 2026 04:41
@DedeHai DedeHai changed the title Add Chinese (zh) translation for all Web UI pages Replace UI text with Chinese (zh) translation Jun 5, 2026
@foxlesbiao
Copy link
Copy Markdown
Author

Hi @DedeHai, thanks for the feedback. I understand that directly replacing all English text is not acceptable for upstream.

I have a question about the multi-language approach: would a build-time locale approach be viable? The idea is:

  • Add a WLED_LOCALE build flag in platformio.ini (e.g. -D WLED_LOCALE=zh_CN)
  • At compile time, the HTML strings get replaced based on the selected locale
  • Zero extra flash overhead — no runtime i18n framework, no separate language files, no additional JS
  • Works within the existing 256KB FS partition limits
  • Users who want a specific language would build from source (or download a pre-built locale variant)

This avoids the runtime switching problem entirely. The trade-off is that users need to pick their language at build time, but for non-English users this is usually a one-time choice.

Is this something the project would accept? If so, I can rework this PR along those lines. If not, could you share what approach (if any) would be acceptable for getting non-English support into upstream?

Thanks!

@DedeHai
Copy link
Copy Markdown
Collaborator

DedeHai commented Jun 5, 2026

In theory yes but it eludes me on how you want to do that. Like replace the htm files with different versions at compile time? how to maintain that?

@foxlesbiao
Copy link
Copy Markdown
Author

Good question. Here is the concrete approach I have in mind:

Implementation: PlatformIO pre-build script

  1. Keep the current English HTML files as-is (the "source of truth")
  2. Add translation JSON files per locale, e.g.:
    locales/
      zh_CN.json  (~600 key-value pairs)
      de_DE.json
      ...
    
  3. Add a PlatformIO pre-build Python script that:
    • Reads the active locale from build_flags (e.g. -D WLED_LOCALE=zh_CN)
    • Looks up the matching JSON file in locales/
    • Replaces tagged strings in the HTML files (via data-i18n attributes or simple marker comments)
    • Writes the processed HTML to the build output directory
  4. If no locale is set (default), the English HTML is used as-is — zero change for existing builds

Maintenance:

  • English HTML remains the primary file — contributors only edit English
  • Translations are separate JSON files — translators only edit JSON, never touch HTML
  • When English strings change, the JSON keys just need updating — no merge conflicts between languages
  • Adding a new language = adding one JSON file + one build env in platformio.ini

Flash impact:

  • Zero — the translated HTML replaces the English version in the build output, not adds to it
  • Works within 256KB FS partitions

What the user gets:

  • A few extra build environments in platformio.ini (e.g. esp32dev_zh_CN, esp32dev_de_DE)
  • Or they add -D WLED_LOCALE=zh_CN to their existing build config
  • Download pre-built firmware for their language from GitHub Releases (if CI is set up)

Would this approach work for you? If so, I can rework this PR to implement it. The current 22 translated HTML files would be converted into one zh_CN.json translation file, and the rest would be the build infrastructure (pre-build script + build env config).

@DedeHai
Copy link
Copy Markdown
Collaborator

DedeHai commented Jun 5, 2026

@netmindz what do you think of the approach proposed?

@foxlesbiao
Copy link
Copy Markdown
Author

You are right to question the approach. After thinking more carefully, here is a better design that avoids touching the original HTML entirely:

Core idea: External toolchain using an HTML parser (BeautifulSoup), not regex.

The problem with regex-based string replacement is that it is fragile — any HTML structure change breaks it. Instead, we use BeautifulSoup to parse the DOM tree, extract translatable text with its DOM path, and replace precisely by node location.

How it works:

tools/i18n/
├── extract.py          # Parse English HTML → generate strings.json template
├── build.py            # Read JSON + English HTML → output translated HTML
└── locales/
    └── zh_CN.json      # Translator fills this in
  1. extract.py parses all 22 English HTML files with BeautifulSoup, extracts every translatable string (innerText, placeholder, title, aria-label, JS innerHTML), and generates a strings.json template with DOM paths:

    {
      "index.htm": {
        "div#topnav > a:nth(0)": "Power",
        "input#penn": {"placeholder": "Search presets..."},
        ...
      }
    }
  2. Translator copies the template to zh_CN.json and fills in translations. No HTML knowledge needed.

  3. build.py reads the JSON, parses the English HTML with BeautifulSoup, matches each entry by DOM path, and writes translated HTML to the build output directory. Original files untouched.

  4. PlatformIO integration via pre-build script:

    [env:esp32dev_zh_CN]
    build_flags = -D WLED_LOCALE=zh_CN
    extra_scripts = pre:tools/i18n/build.py

Why this is better than regex:

  • BeautifulSoup understands HTML structure — survives tag nesting, attribute reordering, whitespace changes
  • Each string is located by DOM path, not text pattern — no risk of false matches
  • If the HTML structure changes significantly (a div removed), the script detects it and reports an error instead of silently replacing the wrong node

Zero impact on WLED codebase:

  • No changes to any existing HTML, JS, or C++ files
  • No data-i18n attributes needed
  • English remains the single source of truth
  • Translation pipeline is fully external
  • Flash impact: zero (replaced, not added)
  • Works within 256KB FS partitions

WLED contributors do not need to care about translations at all. They edit English HTML as always. The toolchain handles everything externally.

Would you accept a PR that adds this toolchain to tools/i18n/ with zh_CN as the first translation?

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