Skip to content

Add Russian localisation - #1

Merged
DDDMUC merged 1 commit into
DDDMUC:mainfrom
aleXela17:ru-localization
Nov 16, 2026
Merged

DDDMUC merged 1 commit into
DDDMUC:mainfrom
aleXela17:ru-localization

Conversation

@aleXela17

Copy link
Copy Markdown
Contributor

This adds a Russian (ru) dictionary to the client bundle and wires it into every surface the plugin renders, so a Russian browser gets Russian text instead of the zh/en fallback.

What changes

src/client.js

  • New ru dictionary with exactly the keys zh and en carry (98 entries), including the function-valued ones for counts and paths, so the numbers still render as numbers.
  • browserLang() recognises ru, and a new activeDictionary() resolves the dictionary once next to the language detection instead of at each call site. Unknown languages keep the historical zh fallback.
  • ru is registered with the host locale namespace ({ zh, en, ru }), so a host that resolves ru natively picks the dictionary up without any further change.
  • For a Russian browser the plugin dictionary answers before the host translator - in the DOM layer (t()) and for the two session-menu rows through a new slotTranslator(). DSH ships no ru locale of its own, and its translator would answer in Chinese or English, so the new dictionary would otherwise never be seen. The zh/en path is untouched: the host translator stays the authority there, which keeps the menu in step when the UI language is changed in the settings.

test/checkbox.dom.test.js

Two tests:

  • ru reaches the host namespace with exactly the zh key set - a missing key would silently fall back to Chinese mid-dialog.
  • with navigator.language set to ru-RU the menu rows render Russian while the harness translator still answers in Chinese, i.e. the Russian choice really comes from the plugin.

README.md

The language claim is now three languages in both language sections.

Not in this pull request

The host-side error bodies in src/index.js (for example the "session is still open" refusal and the file-manager failures) are still Chinese-only. Localising them means teaching the host which language a request wants, which is a larger change and touches the HTTP layer rather than the dictionaries. The client already localises the two refusals a user actually meets - busy and not-found are mapped to busy / notFound before they reach the dialog - so the dialogs and the plugin page are fully Russian; only raw host messages on rarer failures stay Chinese.

Verification

Both suites pass on Node 22:

  • node test/checkbox.dom.test.js - 119 tests, 119 pass
  • node test/artifacts.host.test.js - 98 tests, 98 pass

(The files were run directly because the sandbox this was prepared in cannot spawn the test runner's per-file children; node --test "test/*.test.js" is what CI should use.)

A Russian browser now gets Russian menu rows, dialog, batch bar and plugin
page instead of the zh/en fallback.

- add a ru dictionary (same 98 keys as zh/en, function entries included)
- recognise ru in browserLang() and resolve the dictionary through a single
  activeDictionary() helper
- register ru with the host locale namespace, so a host that resolves ru
  natively picks it up unchanged
- for a Russian browser the plugin dictionary answers before the host
  translator (DOM layer and session-menu rows): DSH ships no ru locale and
  would otherwise answer in zh or en. The zh/en path is untouched
- tests: ru key parity with zh, and Russian menu labels under a ru navigator
@DDDMUC
DDDMUC merged commit cea13a7 into DDDMUC:main Nov 16, 2026
DDDMUC added a commit that referenced this pull request Nov 16, 2026
俄语(社区贡献,PR #1,作者 @aleXela17)
- 新增 ru 字典,98 条与 zh/en 完全对齐,函数型条目仍是函数(数字照常渲染)
- browserLang() 认 ru;activeDictionary() 把「用哪本字典」收成一处
- ru 随 zh/en 一起注册进宿主 locale 命名空间
- DSH 自身没有 ru 语言包,所以俄语浏览器下插件字典优先;中英路径不变,宿主仍是权威
- 两条新增测试:ru 键集与 zh 完全一致;ru-RU 浏览器下菜单行取插件字典

拖拽标签的占位符
- dropRelease 模板是「松手删除「{name}」」,但 localizedTranslator 的插值参数表
  只有 n/done/total/ok/fail/path,没有 name;调用处又把标题当裸字符串传进去
- 结果三种语言都原样显示 {name}。现在传 { name },标题真正进到句子里
- dropHint 没有占位符,顺手不再传参
- 这是 v0.2.4 引入拖拽时留下的,当时的测试只匹配了「松手删除」前缀
- 新增两条测试:不得残留 {name}、必须带上被拖动的会话标题

测试:宿主 98 项、客户端 121 项。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants