Pull requests / #682
#682 serve: a Chinese / English language switch for the web app
closed · @hogtinbao · 0 commentaires · Sur GitHub
Description
## What this adds An optional **Chinese / English language switch** for the web app, with a `Language` button at the left of the header: **English / Simplified Chinese / Chinese + English**. It is opt-in and reversible: the stock interface is what you get until someone picks another language. ## Files | File | Change | | --- | --- | | `serve/web/i18n-zh.js` | new, self-contained | | `serve/web/index.html` | one `<script>` tag | | `serve/web/monitor.html` | one `<script>` tag | No existing function is modified, there is no new dependency, no server-side change and no API change (`/health`, `/v1/...` are untouched — only the two HTML pages load the new file). Removing the feature is deleting one line per page. ## How it works - A dictionary covers the fixed labels; a list of regex rules covers the strings the app builds at run time (token counts, `tok/s`, `N of M servers connected`, the request table, the `Since …` totals line, and so on). - A `MutationObserver` re-translates after the app re-renders, so the live Monitor — the status pill included — keeps updating in the chosen language. - The Chinese and the English text both live in the DOM; a `data-lang` attribute on `<html>` plus CSS decides which one is shown. Switching is instant and does not re-run the translation, so there is no flash. - The choice is kept in `localStorage` (`strata.lang`). ## Guarantees - **The model's output is never rewritten.** Chat text, reasoning, code blocks and MCP tool arguments and results are explicitly excluded. Checked by asking the model for an English answer and confirming the bubble, the reasoning and the code read exactly as the model produced them in every language mode. - **`English` restores the stock interface**, attributes included: every translated `title`, `placeholder` and `aria-label` keeps its original value in a `data-i18n-orig-*` attribute. - Text with no dictionary entry or rule is left alone, so a partial translation never breaks the page. ## Tested On Windows 11 in a real browser against a running server (Qwen3.8-Flash-Next IQ2_XS): all three modes on the Chat, Monitor and About tabs and in the sampling drawer; switching back and forth without a reload; reloading to confirm the stored choice comes back; and the model-output check above. ## Notes - The dictionary is deliberately data rather than code: another language is another table, and the rules are shared. - Happy to rework any of it — different button position, the dictionary split into its own file, a different default — if you would rather have it another way.
Sur le site
Liens install, modèles, releases.