[GH-ISSUE #1230] serve/web: add English / Simplified Chinese (zh-CN) UI localization #507

Closed
opened 2026-11-04 01:43:36 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @btc1000w on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1230

Summary / 概述

Adds a lightweight, dependency-free i18n layer to the Strata web control panel (serve/web/), so the UI can render in English or Simplified Chinese (zh-CN).

为 Strata 网页控制面板(serve/web/)加入一套轻量、无依赖的国际化层,界面可显示 英文 或 简体中文(zh-CN)。

  • Default language is auto-detected: localStorage["strata.lang"], else navigator.language starting with zh → zh-CN, otherwise English.
  • A toggle button in the header (next to the theme button) switches languages at runtime; the choice is remembered.
  • English output is byte-identical to before — English strings are kept as the fallback text, so nothing changes for existing users.

Files / 改动文件

File Change
serve/web/i18n.js new — runtime (t, apply, setLang, onChange)
serve/web/i18n.en.js new — English dictionary
serve/web/i18n.zh-CN.js new — Simplified Chinese dictionary
serve/web/index.html data-i18n* attributes, script tags, language button
serve/web/app.js dynamic strings via t(); /config help via about.cfg.help.<key>
serve/web/monitor.html data-i18n* attributes + script tags
serve/web/monitor.js dynamic strings via t()

tokens.css, components.css, app.css, sprite.svg are untouched (SHA-256 identical to upstream).

Runtime API

window.StrataI18N = {
  lang,                       // "en" | "zh-CN"
  available: ["en", "zh-CN"],
  t(key, vars),               // current dict -> en fallback -> key; {name} interpolation
  apply(root = document),     // data-i18n / -html / -title / -placeholder / -aria; sets <html lang>
  setLang(lang),              // persists to localStorage, applies, dispatches "strata:lang"
  onChange(cb)                // document listener for "strata:lang"
};

Verification / 验证

  • Playwright (Chromium): document.documentElement.lang === "zh-CN"; header tabs, chat, monitor, about and the runtime-generated Model settings form all render Chinese; English still renders exactly as before.
  • node --check clean on all five JS files.
  • Only console message is a pre-existing favicon.ico 404.
  • All 90 element ids in index.html preserved; one id added (lang-btn); no class changes, so no layout regression.

Patch

A git format-patch patch (against main 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253, v0.1.40.1) is available — 7 files changed, +1227 / -269.

git checkout -b i18n-zh-cn 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253
git am 0001-serve-web-add-en-zh-CN-i18n-with-automatic-language-.patch
git push -u origin i18n-zh-cn

I can attach the patch file here or open a PR if you prefer.


Happy to adjust naming, split the dictionaries, or add more languages if you want.

Originally created by @btc1000w on GitHub (Oct 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1230 ## Summary / 概述 Adds a lightweight, dependency-free i18n layer to the Strata web control panel (`serve/web/`), so the UI can render in **English** or **Simplified Chinese (zh-CN)**. 为 Strata 网页控制面板(`serve/web/`)加入一套轻量、无依赖的国际化层,界面可显示 **英文** 或 **简体中文(zh-CN)**。 - Default language is auto-detected: `localStorage["strata.lang"]`, else `navigator.language` starting with `zh` → zh-CN, otherwise English. - A toggle button in the header (next to the theme button) switches languages at runtime; the choice is remembered. - **English output is byte-identical to before** — English strings are kept as the fallback text, so nothing changes for existing users. ## Files / 改动文件 | File | Change | |---|---| | `serve/web/i18n.js` | new — runtime (`t`, `apply`, `setLang`, `onChange`) | | `serve/web/i18n.en.js` | new — English dictionary | | `serve/web/i18n.zh-CN.js` | new — Simplified Chinese dictionary | | `serve/web/index.html` | `data-i18n*` attributes, script tags, language button | | `serve/web/app.js` | dynamic strings via `t()`; `/config` help via `about.cfg.help.<key>` | | `serve/web/monitor.html` | `data-i18n*` attributes + script tags | | `serve/web/monitor.js` | dynamic strings via `t()` | `tokens.css`, `components.css`, `app.css`, `sprite.svg` are **untouched** (SHA-256 identical to upstream). ## Runtime API ```js window.StrataI18N = { lang, // "en" | "zh-CN" available: ["en", "zh-CN"], t(key, vars), // current dict -> en fallback -> key; {name} interpolation apply(root = document), // data-i18n / -html / -title / -placeholder / -aria; sets <html lang> setLang(lang), // persists to localStorage, applies, dispatches "strata:lang" onChange(cb) // document listener for "strata:lang" }; ``` ## Verification / 验证 - Playwright (Chromium): `document.documentElement.lang === "zh-CN"`; header tabs, chat, monitor, about and the runtime-generated **Model settings** form all render Chinese; English still renders exactly as before. - `node --check` clean on all five JS files. - Only console message is a pre-existing `favicon.ico` 404. - All 90 element ids in `index.html` preserved; one id added (`lang-btn`); no class changes, so no layout regression. ## Patch A `git format-patch` patch (against `main` `82f46a8c8f475f001ad76d92f58f4a4f8ffb0253`, v0.1.40.1) is available — 7 files changed, +1227 / -269. ```sh git checkout -b i18n-zh-cn 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253 git am 0001-serve-web-add-en-zh-CN-i18n-with-automatic-language-.patch git push -u origin i18n-zh-cn ``` I can attach the patch file here or open a PR if you prefer. --- Happy to adjust naming, split the dictionaries, or add more languages if you want.
Author
Owner

@btc1000w commented on GitHub (Oct 6, 2026):

i18n-zh-cn-patch.txt

<!-- gh-comment-id:6022371476 --> @btc1000w commented on GitHub (Oct 6, 2026): [i18n-zh-cn-patch.txt](https://github.com/user-attachments/files/33119069/i18n-zh-cn-patch.txt)
Author
Owner

@btc1000w commented on GitHub (Oct 6, 2026):

Attached the git format-patch patch: i18n-zh-cn-patch.txt (148,679 B; 7 files changed, +1227 / -269).

GitHub rejects the .patch extension, so it is uploaded as .txt — rename it back to .patch and apply:

git checkout -b i18n-zh-cn 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253
git am i18n-zh-cn-patch.patch
git push -u origin i18n-zh-cn
<!-- gh-comment-id:6022437046 --> @btc1000w commented on GitHub (Oct 6, 2026): Attached the `git format-patch` patch: **i18n-zh-cn-patch.txt** (148,679 B; 7 files changed, +1227 / -269). GitHub rejects the `.patch` extension, so it is uploaded as `.txt` — rename it back to `.patch` and apply: ```sh git checkout -b i18n-zh-cn 82f46a8c8f475f001ad76d92f58f4a4f8ffb0253 git am i18n-zh-cn-patch.patch git push -u origin i18n-zh-cn ```
Author
Owner

@DDK00011 commented on GitHub (Oct 10, 2026):

I built on this patch and added 12 more UI dictionaries: ko, ja, vi, id, zh-TW, es, pt-BR, de, fr, ru, it, tr. Each one has the 373 strings that the web app and the API Monitor page use. Everything is under serve/web/ (new i18n.<code>.js files, i18n.js, index.html, monitor.html, app.js, monitor.js). It is applied on top of current main (fb58e0d); two strings that main added after the patch (monitor.sub.gpuNa, monitor.sub.gpuNoteWinAmd) are translated too.

  • The EN / 中 toggle became a language <select> (in the header on wide screens, in About > Settings on narrow ones). The language still follows the browser language by default, so English browsers see no change.
  • By script: every key is present in every dictionary, and {placeholders}, HTML tags, product names, flags and numbers are unchanged.
  • In a real browser (14 languages x 10 views, desktop and phone/tablet widths): no page errors, no horizontal overflow, no cut-off text, no key falling back to English. The existing tests that read the web files (test_monitor, test_runconfig) pass.
  • The translations are AI first drafts (Gemini 3.8 Flash), followed by AI review passes, one of them on screenshots of every screen. No native speaker has read them yet.

I can open a PR on top of this patch, or post the patch here, if you want it. I also saw #1204, #1427 (ru) and #1152 (ar), which add other language switches. I would rather not collide with them, so tell me which direction you prefer.

<!-- gh-comment-id:6094700138 --> @DDK00011 commented on GitHub (Oct 10, 2026): I built on this patch and added 12 more UI dictionaries: `ko`, `ja`, `vi`, `id`, `zh-TW`, `es`, `pt-BR`, `de`, `fr`, `ru`, `it`, `tr`. Each one has the 373 strings that the web app and the API Monitor page use. Everything is under `serve/web/` (new `i18n.<code>.js` files, `i18n.js`, `index.html`, `monitor.html`, `app.js`, `monitor.js`). It is applied on top of current `main` (`fb58e0d`); two strings that `main` added after the patch (`monitor.sub.gpuNa`, `monitor.sub.gpuNoteWinAmd`) are translated too. - The EN / 中 toggle became a language `<select>` (in the header on wide screens, in About > Settings on narrow ones). The language still follows the browser language by default, so English browsers see no change. - By script: every key is present in every dictionary, and `{placeholders}`, HTML tags, product names, flags and numbers are unchanged. - In a real browser (14 languages x 10 views, desktop and phone/tablet widths): no page errors, no horizontal overflow, no cut-off text, no key falling back to English. The existing tests that read the web files (`test_monitor`, `test_runconfig`) pass. - The translations are AI first drafts (Gemini 3.8 Flash), followed by AI review passes, one of them on screenshots of every screen. No native speaker has read them yet. I can open a PR on top of this patch, or post the patch here, if you want it. I also saw #1204, #1427 (ru) and #1152 (ar), which add other language switches. I would rather not collide with them, so tell me which direction you prefer.
Author
Owner

@Moge800 commented on GitHub (Oct 11, 2026):

Hi @DDK00011, I can help proofread the Japanese translations if needed!

<!-- gh-comment-id:6108340613 --> @Moge800 commented on GitHub (Oct 11, 2026): Hi @DDK00011, I can help proofread the Japanese translations if needed!
Author
Owner

@DDK00011 commented on GitHub (Oct 11, 2026):

Hi @Moge800, thank you so much for offering—yes please, I would love your help!

The Japanese dictionary is in serve/web/i18n.ja.js in draft PR https://github.com/Niko1221/Strata/pull/1973 (375 UI strings). The text is an AI first draft followed by AI review passes; no native speaker has read it yet. The easiest way to review is right on that file: leave a comment on a line, or use GitHub's "suggest changes" block. There is no need to fix everything; even a few corrections already help a lot!

I am mainly unsure about three things:

  1. Japanese terms for technical words (prefill, decode, expert cache, VRAM, draft)
  2. The politeness level
  3. Any line that reads like machine translation

If you run the app, you can pick 日本語 in the language menu (in the header, or in About > Settings on narrow screens).

Prepared with the help of Claude Code.

<!-- gh-comment-id:6111638168 --> @DDK00011 commented on GitHub (Oct 11, 2026): Hi @Moge800, thank you so much for offering—yes please, I would love your help! The Japanese dictionary is in `serve/web/i18n.ja.js` in draft PR https://github.com/Niko1221/Strata/pull/1973 (375 UI strings). The text is an AI first draft followed by AI review passes; no native speaker has read it yet. The easiest way to review is right on that file: leave a comment on a line, or use GitHub's "suggest changes" block. There is no need to fix everything; even a few corrections already help a lot! I am mainly unsure about three things: 1. Japanese terms for technical words (prefill, decode, expert cache, VRAM, draft) 2. The politeness level 3. Any line that reads like machine translation If you run the app, you can pick 日本語 in the language menu (in the header, or in About > Settings on narrow screens). _Prepared with the help of Claude Code._
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6156035833 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#507
No description provided.