mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-24 10:27:44 -06:00
WordCraft's interface can now be shown in Simplified Chinese, Traditional Chinese or Japanese as well as English. The new `language` setting is `auto` by default: the UI follows the operating system's preferred languages (Windows display language, macOS preferred languages, LANG/LC_* on Unix, via sys-locale; WORDCRAFT_LANGUAGE overrides) when there is a catalog for one of them, and English otherwise. File > Options > Interface language picks one by hand, and the `ui.language` command does the same for scripts and agents. The setting persists with the other UI preferences. The i18n module is PdfCraft's (catalog format, parser, locale matching), trimmed to plain entries. English strings in the code are the keys; the ribbon helpers (group, big, small, split, menu_button, menu items, tooltips and ribbon locations), tabs, Backstage, Options, dialogs, panes, the status bar, the context menu and command search translate at draw time. Command ids, documents, the CLI, MCP and the control channel stay English. Catalogs hold ~780 entries per language, written clean-room from the English meaning. Chinese interfaces put the craft-fonts Chinese face before the Japanese one so a line never mixes glyph styles; fonts are reinstalled when the language changes. Fixes #8. Claude-Session: https://claude.ai/code/session_019FczntrDNYd6DupyBdpbL5 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <shared2@storyteller.ai>
2.0 KiB
2.0 KiB
Control protocol
Start the app with a control port: wordcraft --control 7981 (or WORDCRAFT_CONTROL_PORT=7981).
It listens on 127.0.0.1 only. Send one JSON object per line; each gets one reply line:
{"id": 1, "method": "engine.execute", "params": {"command": "text.insert", "params": {"text": "Hello"}}}
{"id": 1, "ok": true, "result": {"anchor": {...}, "focus": {...}}}
Errors come back as {"id": …, "ok": false, "error": "message"}. A failed command leaves the
document unchanged.
Methods
| Method | Params | Result |
|---|---|---|
engine.execute |
command, params |
the command's result (any id from engine.commands, including UI commands ui.tab, ui.dialog, ui.backstage, ui.language (`{"value": "auto" |
engine.commands |
— | every command: id, label, location, shortcut, params, enabled |
document.inspect |
text? |
blocks (text, style, runs, lists, tables), parts, sections, selection, pages |
ui.inspect |
— | UI state, view, dialog, window size, page rects on screen, caret, perf |
ui.click |
x, y, button?, count?, shift?, cmd?, alt? |
real pointer input at window coordinates |
ui.clickText |
page (0-based), x, y (points from the page's top-left), count? |
click inside a page |
ui.move / ui.drag |
x,y / x,y,toX,toY,steps? |
pointer move / drag |
ui.key |
key (B, Enter, Left…), shift?, alt?, cmd? |
key press through egui (shortcuts apply) |
ui.text |
text |
typed text through egui |
ui.screenshot |
path? |
PNG of the window |
ui.render |
path, page? (1-based), scale? |
PNG of a page, rendered by the engine |
ui.parity |
— | feature-catalog parity |
ui.resize / ui.focus / app.quit |
window control |
Any other method name is treated as a command id: {"method": "format.bold"} works.
Positions are {"story": "body" | {"part": n}, "path": [block, row, cell, block, …], "off": byteOffset}.