From 733fe56263570fec7939f4b122147aa9d139f883 Mon Sep 17 00:00:00 2001 From: foxlesbiao Date: Fri, 5 Jun 2026 10:01:34 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=B8=AD=E6=96=87=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E6=88=90=E5=85=A8=E9=83=A822=E4=B8=AAWeb=20U?= =?UTF-8?q?I=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已翻译文件: - 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 --- wled00/data/404.htm | 10 +- wled00/data/dmxmap.htm | 6 +- wled00/data/edit.htm | 28 +-- wled00/data/index.htm | 190 ++++++++++---------- wled00/data/liveview.htm | 4 +- wled00/data/liveviewws2D.htm | 4 +- wled00/data/msg.htm | 8 +- wled00/data/settings.htm | 26 +-- wled00/data/settings_2D.htm | 92 +++++----- wled00/data/settings_dmx.htm | 32 ++-- wled00/data/settings_leds.htm | 300 +++++++++++++++---------------- wled00/data/settings_pin.htm | 10 +- wled00/data/settings_pininfo.htm | 24 +-- wled00/data/settings_sec.htm | 74 ++++---- wled00/data/settings_sync.htm | 206 ++++++++++----------- wled00/data/settings_time.htm | 114 ++++++------ wled00/data/settings_ui.htm | 98 +++++----- wled00/data/settings_um.htm | 42 ++--- wled00/data/settings_wifi.htm | 102 +++++------ wled00/data/update.htm | 50 +++--- wled00/data/usermod.htm | 4 +- wled00/data/welcome.htm | 20 +-- 22 files changed, 721 insertions(+), 723 deletions(-) diff --git a/wled00/data/404.htm b/wled00/data/404.htm index caf6856def..096a38eb88 100644 --- a/wled00/data/404.htm +++ b/wled00/data/404.htm @@ -1,10 +1,10 @@ - + - Not found + 未找到 - - - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/wled00/data/settings_2D.htm b/wled00/data/settings_2D.htm index 76f84fa61b..5992f06f57 100644 --- a/wled00/data/settings_2D.htm +++ b/wled00/data/settings_2D.htm @@ -1,9 +1,9 @@ - + - 2D Set-up + 2D 设置 @@ -252,61 +252,61 @@
-
+
-

2D setup

+

2D 设置

- Strip or panel: + 灯带或面板:

- +
diff --git a/wled00/data/settings_dmx.htm b/wled00/data/settings_dmx.htm index 391c2bdc97..0e6e1a75ea 100644 --- a/wled00/data/settings_dmx.htm +++ b/wled00/data/settings_dmx.htm @@ -1,9 +1,9 @@ - + - DMX Settings + DMX 设置 - -

Pin Info

-
Loading...
- + +

引脚信息

+
加载中...
+ diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index 4586d44a5d..19ae63b80a 100644 --- a/wled00/data/settings_sec.htm +++ b/wled00/data/settings_sec.htm @@ -1,9 +1,9 @@ - + - Security & Update Setup + 安全和更新设置 blocks instead of the entire file, preventing cross-block matching errors 4. Safe default output: --output-dir defaults to a temp directory instead of overwriting English source files. Added safety warning when output == source. --- tools/i18n/build.py | 175 +++++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 61 deletions(-) diff --git a/tools/i18n/build.py b/tools/i18n/build.py index 6aa733eb23..dc1dda9677 100644 --- a/tools/i18n/build.py +++ b/tools/i18n/build.py @@ -1,13 +1,19 @@ #!/usr/bin/env python3 """ -WLED i18n Build Script (v2 - surgical replacement) +WLED i18n Build Script (v3 - fixes from coderabbitai review) Generates translated HTML files from English source + locale JSON. Uses raw string replacement instead of BeautifulSoup serialization to preserve original HTML formatting exactly (critical for ESP32 flash size). +Fixes applied: +1. File-scoped HTML replacement (no cross-file bleed) +2. Script-block-aware HTML replacement (skip )', re.DOTALL | re.IGNORECASE) + last_end = 0 + + for match in pattern.finditer(content): + # Non-script content before this script block + before = content[last_end:match.start()] + if before: + segments.append((before, False)) + # The script block itself (including tags) + segments.append((match.group(0), True)) + last_end = match.end() + + # Remaining non-script content after last script block + after = content[last_end:] + if after: + segments.append((after, False)) + + return segments def replace_html_text(content, original, translated): @@ -66,12 +99,13 @@ def replace_html_text(content, original, translated): - >original< (direct child text) - > original < (with whitespace) - >... original< (text after sibling element) + + IMPORTANT: content must be non-script segments only. """ escaped = re.escape(original) total = 0 # Pattern 1: Text between > and or > and < (with optional whitespace) - # Matches: >text< and >text p1 = re.compile(r'(>)\s*(' + escaped + r')\s*(' + translated + r'\g<3>', content) total += n @@ -90,10 +124,7 @@ def replace_html_text(content, original, translated): def replace_html_attr(content, attr, original, translated): - """Replace HTML attribute value using exact string matching. - Finds: attr="original" and replaces with attr="translated" - """ - # Match attribute="value" with exact value + """Replace HTML attribute value using exact string matching.""" pattern = re.compile( r'(' + re.escape(attr) + r'\s*=\s*")(' + re.escape(original) + r')(")', re.IGNORECASE @@ -102,34 +133,30 @@ def replace_html_attr(content, attr, original, translated): return new_content, count -def replace_js_string(content, original, translated): - """Replace a JS string literal in block. + Returns (new_block, count). """ for quote in ['"', "'", '`']: escaped = re.escape(original) - # Match the string within quotes, only inside