mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1427] [CLOSED] web: Russian and Chinese UI localization (dictionary + header language picker) #3447
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#3447
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/1427
Author: @Astemiir
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:i18n-ru📝 Commits (2)
350c5c9web: Russian UI localization (dictionary + header language picker)e9f4856i18n: 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
serve/web/i18n.js— the translator and the picker. Walks the DOM, replaces exact dictionary matches and keeps aMutationObserveron 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#chatonly the chrome listed inCHROME_SELis translated.serve/web/i18n-ru.jsonandserve/web/i18n-zh.json— 391 flat"english": "translation"pairs each, with_codeand_nameat the top. The reverse direction is built by inversion, so one file works both ways; a new language is just anotheri18n-<code>.jsonfile.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 theserve/web/i18n-*.jsonfiles with their_code/_name) and".json": "application/json; charset=utf-8"in the/web/types (+20/−1).serve/web/index.html— the stylesheet link, theEnbutton left of the status pill, the pill slot, andi18n.jsbeforeapp.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
localStorageunderstrata.lang(same convention asstrata.theme), anddocument.documentElement.langfollows 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
<b>,<code>), so their fragments would need separate pairs. If you prefer, I can switch those few todata-i18nkeys instead of translating text nodes — your call.python -m py_compile serve/server.py,node --check serve/web/i18n.js, both dictionaries parse (393 keys each: 391 pairs plus_codeand_name), and/web/i18n-indexreturns the list on a live 0.1.45 install.servefolder 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.