[PR #1427] [CLOSED] web: Russian and Chinese UI localization (dictionary + header language picker) #3447

Closed
opened 2026-11-07 14:41:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1427
Author: @Astemiir
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: i18n-ru


📝 Commits (2)

  • 350c5c9 web: Russian UI localization (dictionary + header language picker)
  • e9f4856 i18n: flat dictionaries for Russian and Chinese, language list from the server

📊 Changes

7 files changed (+1220 additions, -4 deletions)

View changed files

📝 serve/server.py (+20 -1)
➕ serve/web/i18n-ru.json (+395 -0)
➕ serve/web/i18n-zh.json (+395 -0)
➕ serve/web/i18n.css (+46 -0)
➕ serve/web/i18n.js (+356 -0)
📝 serve/web/index.html (+5 -2)
📝 serve/web/monitor.html (+3 -1)

📄 Description

Summary

Adds Russian and Chinese localization of the web UI. It is deliberately non-invasive: the interface code keeps its English strings, and a self-contained script translates the visible chrome from flat JSON dictionaries, so the patch does not touch app logic, needs no build step and adds no dependencies. English stays the default — the language only changes when the user picks it.

What changed

  • new serve/web/i18n.js — the translator and the picker. Walks the DOM, replaces exact dictionary matches and keeps a MutationObserver on the body, so text the app renders later (metrics, status labels, toasts) is translated in the observer's microtask — before the frame is painted. Strings with numbers (1 token / 2 tokens / 5 tokens) go through a rule table per language, since a flat dictionary cannot express plurals. The language list comes from the server (GET /web/i18n-index), so adding a language needs no code change; picking one reloads the page, the simplest way to apply a dictionary to the whole document. Model answers, code blocks and attachments are never touched: inside #chat only the chrome listed in CHROME_SEL is translated.
  • new serve/web/i18n-ru.json and serve/web/i18n-zh.json — 391 flat "english": "translation" pairs each, with _code and _name at the top. The reverse direction is built by inversion, so one file works both ways; a new language is just another i18n-<code>.json file.
  • new serve/web/i18n.css — the picker button, the drop-down menu and a fixed-width slot for the status pill.
  • serve/server.py — GET /web/i18n-index (lists the serve/web/i18n-*.json files with their _code/_name) and ".json": "application/json; charset=utf-8" in the /web/ types (+20/−1).
  • serve/web/index.html — the stylesheet link, the En button left of the status pill, the pill slot, and i18n.js before app.js (so the static header is translated before the app renders and before the first paint).
  • serve/web/monitor.html — the same script and picker in the monitor window's own header, so the standalone monitor is translated as well.

The choice is remembered in localStorage under strata.lang (same convention as strata.theme), and document.documentElement.lang follows it.

Coverage. Every string the pages and their scripts can show is translated except, intentionally: the brand name, the sample URLs, the dash placeholders and the sampler labels Top-p, Top-k, Seed (parameter names).

Extra Notes

  • Unknown text simply stays English, so a missing pair never breaks a page. A dictionary that fails to load falls back to English and re-labels the button.
  • Known limitation: a few long sentences in the About card are split across inline tags (<b>, <code>), so their fragments would need separate pairs. If you prefer, I can switch those few to data-i18n keys instead of translating text nodes — your call.
  • Verified locally: python -m py_compile serve/server.py, node --check serve/web/i18n.js, both dictionaries parse (393 keys each: 391 pairs plus _code and _name), and /web/i18n-index returns the list on a live 0.1.45 install.
  • For anyone who wants to try it before this is merged, the same change is packed as a drop-in overlay for a stock 0.1.45 (copy the serve folder over the install, restart, Ctrl+F5; README in English, Russian and Chinese): https://github.com/Astemiir/Strata/releases/download/i18n-0.1.45/strata-i18n-0.1.45.zip

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1427 **Author:** [@Astemiir](https://github.com/Astemiir) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `i18n-ru` --- ### 📝 Commits (2) - [`350c5c9`](https://github.com/Niko1221/Strata/commit/350c5c949539e9cf681d422d96dd114e28fdf58f) web: Russian UI localization (dictionary + header language picker) - [`e9f4856`](https://github.com/Niko1221/Strata/commit/e9f485648e63906f9a77d012ced02d62dc1415ad) i18n: flat dictionaries for Russian and Chinese, language list from the server ### 📊 Changes **7 files changed** (+1220 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+20 -1) ➕ `serve/web/i18n-ru.json` (+395 -0) ➕ `serve/web/i18n-zh.json` (+395 -0) ➕ `serve/web/i18n.css` (+46 -0) ➕ `serve/web/i18n.js` (+356 -0) 📝 `serve/web/index.html` (+5 -2) 📝 `serve/web/monitor.html` (+3 -1) </details> ### 📄 Description ## Summary Adds Russian and Chinese localization of the web UI. It is deliberately **non-invasive**: the interface code keeps its English strings, and a self-contained script translates the visible chrome from flat JSON dictionaries, so the patch does not touch app logic, needs no build step and adds no dependencies. English stays the default — the language only changes when the user picks it. ## What changed * **new `serve/web/i18n.js`** — the translator and the picker. Walks the DOM, replaces exact dictionary matches and keeps a `MutationObserver` on the body, so text the app renders later (metrics, status labels, toasts) is translated in the observer's microtask — before the frame is painted. Strings with numbers (1 token / 2 tokens / 5 tokens) go through a rule table per language, since a flat dictionary cannot express plurals. The language list comes from the server (`GET /web/i18n-index`), so adding a language needs no code change; picking one reloads the page, the simplest way to apply a dictionary to the whole document. Model answers, code blocks and attachments are never touched: inside `#chat` only the chrome listed in `CHROME_SEL` is translated. * **new `serve/web/i18n-ru.json` and `serve/web/i18n-zh.json`** — 391 flat `"english": "translation"` pairs each, with `_code` and `_name` at the top. The reverse direction is built by inversion, so one file works both ways; a new language is just another `i18n-<code>.json` file. * **new `serve/web/i18n.css`** — the picker button, the drop-down menu and a fixed-width slot for the status pill. * **`serve/server.py`** — `GET /web/i18n-index` (lists the `serve/web/i18n-*.json` files with their `_code`/`_name`) and `".json": "application/json; charset=utf-8"` in the `/web/` types (+20/−1). * **`serve/web/index.html`** — the stylesheet link, the `En` button left of the status pill, the pill slot, and `i18n.js` before `app.js` (so the static header is translated before the app renders and before the first paint). * **`serve/web/monitor.html`** — the same script and picker in the monitor window's own header, so the standalone monitor is translated as well. The choice is remembered in `localStorage` under `strata.lang` (same convention as `strata.theme`), and `document.documentElement.lang` follows it. **Coverage.** Every string the pages and their scripts can show is translated except, intentionally: the brand name, the sample URLs, the dash placeholders and the sampler labels `Top-p`, `Top-k`, `Seed` (parameter names). ## Extra Notes * Unknown text simply stays English, so a missing pair never breaks a page. A dictionary that fails to load falls back to English and re-labels the button. * Known limitation: a few long sentences in the About card are split across inline tags (`<b>`, `<code>`), so their fragments would need separate pairs. If you prefer, I can switch those few to `data-i18n` keys instead of translating text nodes — your call. * Verified locally: `python -m py_compile serve/server.py`, `node --check serve/web/i18n.js`, both dictionaries parse (393 keys each: 391 pairs plus `_code` and `_name`), and `/web/i18n-index` returns the list on a live 0.1.45 install. * For anyone who wants to try it before this is merged, the same change is packed as a drop-in overlay for a stock 0.1.45 (copy the `serve` folder over the install, restart, Ctrl+F5; README in English, Russian and Chinese): https://github.com/Astemiir/Strata/releases/download/i18n-0.1.45/strata-i18n-0.1.45.zip --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:32 +07:00
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#3447
No description provided.