Document the translation dispatcher and capability handshake
This commit is contained in:
+10
-5
@@ -55,6 +55,9 @@ class Data(msgspec.Struct):
|
||||
#: API key gating the translator service WebSocket (/_translate/{key});
|
||||
#: generated lazily at startup (see the lifespan in app.py).
|
||||
translate_key: str = ""
|
||||
#: Wanted target languages for the translator service (presence-keys);
|
||||
#: jobs are offered only in these ∩ a connection's capabilities.
|
||||
translate_langs: dict[str, True] = {}
|
||||
#: All original-language text, content-addressed: blake3(normalized)
|
||||
#: digest[:9] -> Markdown chunk. Shared by every article. Keys are
|
||||
#: bytes; kanta/msgspec base64-encode them at the JSON level.
|
||||
@@ -94,11 +97,13 @@ alternate links never enumerate chunks. It is written by whoever writes
|
||||
translation data, in the same transaction:
|
||||
|
||||
- **Translator service:** the WebSocket API at `/_translate/{key}` (see
|
||||
docs/localization.md) pushes pending fragments (titles + translatable
|
||||
chunks lacking an entry, deduped by hash) and receives result batches;
|
||||
storing a batch writes `trans[h][lang]` entries, sets
|
||||
`node.langs[lang] = True` on every article that gained one and
|
||||
invalidates the page cache — all in one transaction.
|
||||
docs/localization.md) offers pending fragments (titles + translatable
|
||||
chunks lacking an entry for the language) as single-item jobs — one at
|
||||
a time per connection, in `Data.translate_langs` ∩ the connection's
|
||||
announced capabilities — and receives the matching result; storing it
|
||||
writes the `trans[h][lang]` entry, sets `node.langs[lang] = True` on
|
||||
every article that gained one and invalidates the page cache — all in
|
||||
one transaction.
|
||||
- **Translated-view save:** appending the first patch for `f"{path}:{lang}"`
|
||||
sets `node.langs[lang] = True` (patches alone make the version exist).
|
||||
- **Removals:** deleting a patch or GC'ing translations re-derives the key:
|
||||
|
||||
Reference in New Issue
Block a user