mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3293] [CLOSED] [GUI] serve: a Chinese / English language switch for the web app (adapted to 0.2.6) #4550
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4550
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3293
Author: @hogtinbao
Created: 10/19/2026
Status: ❌ Closed
Base:
main← Head:web-ui-zh📝 Commits (1)
87fbf2eserve: a Chinese / English language switch for the web app (adapted to 0.2.6)📊 Changes
3 files changed (+747 additions, -0 deletions)
View changed files
➕
serve/web/i18n-zh.js(+745 -0)📝
serve/web/index.html(+1 -0)📝
serve/web/monitor.html(+1 -0)📄 Description
Problem and result
The web UI in
serve/web/is English-only. On a Chinese Windows install the settings page, the sampling drawer, the monitor table and even the server's own validation errors are unreadable to the person running the model, and there is no hook to translate them without editingapp.js/monitor.js— files upstream rewrites regularly.This PR adds a self-contained translation layer that is opt-in at runtime: one new file
serve/web/i18n-zh.jsplus one<script>line in each page. ALanguagecontrol in the header switches between English, 简体中文 and 中英文 (Chinese with the English original in small type beneath it). The default stays English, so anyone who never touches the control sees the current UI. Model output is never rewritten — chat bubbles, thinking, code blocks and tool-call payloads are in the skip list.Related discussion
This replaces #1836 — the earlier revision of this change (adapted to v0.1.45), closed by the 0.2.0-beta tracker reset, not on merit.
/reopenon that PR failed withValidation Failedafter the branch was force-pushed to this revision, so this is a fresh pull request with the same change.Current revision: rebased onto
4b9e05a2(= tagv0.2.6) and re-checked against everyserve/web,serve/runconfig.py,serve/telemetry.pyandserve/frontend.pychange since the 0.2.0-beta basee88ee39d(969 commits, four of them touchingserve/web/).Since the 0.2.0-beta revision
The upstream diff between
e88ee39dandv0.2.6adds exactly these user-visible strings, and all of them are covered now:serve/web/app.js(#3435, "use an edited API key at once, even when browser storage is blocked"): two new toasts —API key used for this page onlyandBrowser storage is unavailable. Enter it again after reloading.Both are dictionary entries. The other threeserve/web/commits in that range (#3594, #3601, #2971) only touch CSS and DOM structure and add no text;index.htmlandmonitor.htmlare byte-identical to the base revision.serve/runconfig.py: one new editable key,mtp(draft layer). Its help sentence is in the dictionary as data (like the other 15), andmtphas a gloss in the monospace key table (草稿层(MTP)).serve/frontend.py: three client-visible rejections the page prints verbatim — a reasoning effort outside the family's list (… use none, low, medium, high, max or 1..100, both the numeric and the word form), an empty message list, and a whitespace tool name. All three are regex rules now. The rest of that file's new text is docstrings and comments, which no page shows.serve/telemetry.pyis unchanged since the base revision.0 · greedy: the readoutapp.jsshows at temperature 0. It was in the v0.1.45 revision (#1836) and went missing when this file was rebuilt for 0.2.0-beta;app.jsstill renders that exact label, so the entry is back.Approach
app.js,monitor.jsorapp.css; each page gets a single script tag. If the file is absent the pages behave exactly as today.56.9 tok/s,3,201 tokens · 12.3 tok/s,Saved (…); the earlier file is ….bak. Start the model again to use it.). AMutationObservertranslates nodes the pages create later, andtitle/placeholder/aria-label/<option>text is translated too./configremain English (only the option text is translated), so the layer cannot change what the server stores.Validation
Passed:
python -m unittest discover -s serve -p 'test_*.py'on this branch — Windows 11, Python 3.12.10, revision87fbf2e6rebased on4b9e05a2(v0.2.6):Ran 1035 tests in 413.981s ... FAILED (failures=1, errors=1, skipped=21)(see Failed).index.htmlandmonitor.htmlfromv0.2.6with this layer attached (served statically on127.0.0.1, Edge/Chromium engine): the script loads,<html data-lang>is set, the header gets theLanguagecontrol, and the tabs read 聊天 / 图片 / 监控 / 关于 with the English original beneath in 中英文 mode;monitor.htmltranslates its own headings; pickingEnglishsetsdata-lang="en"and storesstrata.lang="en". The live API was not attached, so only the static chrome was exercised this way (see Not run).node --check serve/web/i18n-zh.js— no syntax errors (re-run on this revision).mtphelp sentence exactly asrunconfig.pyconcatenates it, the three newfrontend.pyrejections, and four controls from earlier revisions (0 · greedy,Sampling saved,Prefill t/s, the save-confirmation sentence). All 11 return a translation.serve/web,serve/runconfig.py,serve/telemetry.pyandserve/frontend.pybetweene88ee39dand4b9e05a2was extracted with a small local script (HTML text nodes,title/placeholder/aria-label,<option>, JS string literals, theEDITABLEhelp sentences) and matched against the dictionary and the rules; the same diffs were also read by hand, since the extractor is line-based and can miss a string split across lines. What does not match is docstrings, comments, log-only text, DOM ids/classes and the literals that are data (strata.localStorage prefix) — nothing a person reads on the page. The only items deliberately left English are the proper nouns and symbolsStrata,Top-p,Top-k.serve/runconfig.pyare matched by the layer's rules, plus the three newserve/frontend.pyones.serve/server.pystarted with the layer attached;/healthreturned{"status": "ok", "loaded": true, "images": true, "image_generation": true, ...}; a/v1/chat/completionsrequest withreasoning_effort: "none"answered normally (18 tokens,finish_reason: "stop") — the API path is untouched.curl /andcurl /api-monitorreturned the pages with the added script tag andcurl /web/i18n-zh.jsserved HTTP 200 — recorded on the 0.2.0-beta revision of this branch against the live server; the two script lines are unchanged here and were re-checked by reading the served 0.2.6 pages in the browser pass above.Failed:
serve/test_winjob.py::test_children_end_with_a_killed_server—TypeError: argument of type 'NoneType' is not iterableattest_winjob.py:32(the job-object query returns nothing on this machine). Same as on the 0.2.0-beta revision of this branch: environmental, not caused by this change.serve/test_parallel.py::ParallelService::test_benchmark_cancel_suite_releases_batch_queue_and_slots— thecancel_queuedstep reportstarget seen False. It reproduces identically on pristine4b9e05a2in a clean worktree without this branch (Ran 1 test in 36.7s ... FAILED (failures=1)), so it is base/machine timing behaviour. This branch adds no Python file:serve/web/i18n-zh.jsplus one<script>line in each page.Not run:
mtpsettings row, the three new rejections — only appear when the page talks to a 0.2.6 server, and this machine runs 0.2.0-beta, which does not contain them; they were verified against the exact literals the 0.2.6 files produce instead (node + the static re-check).--dump-domhangs against the live page on this machine because it streams/metrics, so there is no scripted UI check in this PR.apps/host) — it has its own strings and is untouched here.Limits
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.