Elffuss BraidHub

kikocis/utopia public

dev · 4.9 KiBRenderedRawPermalink
1# 0004 · Language follows the reader of each text
2
3- **Status**: Built · UI strings in `web/src/i18n/`; user-reachable server errors carry a
4 `code` (`AppError::Invalid`, 81 sites; 23 `Validation` guards stay English);
5 `description` follows `knowledge_bases.ontology_lang`; LLM output for people takes
6 `locale` from the request; extracted data stays verbatim; the UI does not guess the
7 browser language yet.
8- **Written**: 2026-08-29 · condensed into English 2026-09-03
9- **Related**: [0001](0001-ontology-import-and-governance.md) made `description`
10 load-bearing; [0003](0003-ontology-growth-loop.md) separated `reason` from
11 `description`; [0008](0008-ontology-packs-as-cold-start.md) supplies the English packs a
12 Chinese knowledge base starts from.
13
14## The problem
15
16One language switch cannot serve five kinds of text with different readers and sources:
17
18| Text | Reader | Source |
19|---|---|---|
20| UI strings ("Import an ontology") | people | the i18n bundle |
21| Server errors ("Password must be at least 8 characters") | people | Rust |
22| Ontology `label` / `description` | the model reads `description` | packs, users, OWL import |
23| LLM text generated on the spot (a suggested `reason`) | people | the model, on demand |
24| Extracted data (`张三`, `surface_predicate` "runs on") | people and the model | the document, verbatim |
25
26The last row is not copy. It is a quotation.
27
28## Decisions
29
301. **UI strings are a per-person client setting**, like dark mode: a foreign colleague in
31 a Chinese company should not need an administrator to see English. Kept in
32 `localStorage` via `makeStore`, resolved in one function that everything else consumes.
33 The Chinese bundle is `const zh: typeof S = { … }`: a missing key fails compilation,
34 where `Partial` with fallback would leave a silently English line.
352. **Server errors become keys.** With the locale in the client, any string left in Rust
36 is permanently untranslatable. Errors a user can hit are `AppError::Invalid` with a
37 `code` for the frontend `err.*` table (the English `message` stays for MCP, CLI and
38 logs). API-contract guards (`role must be admin, editor or viewer`) stay English
39 `Validation`: their reader is a developer. Hence a hard rule: **the server produces no
40 display text**.
413. **Ontology `description` follows the corpus.** It goes verbatim into the extraction
42 prompt beside the documents, and Chinese UI with English class descriptions is common.
43 So it is a knowledge-base property, `knowledge_bases.ontology_lang`, whose deployment
44 default is named "default ontology language for new knowledge bases"; call it "system
45 language" and someone will hang the UI language on it.
464. **`label` is data and follows no switch.** A class a Chinese team named `人物` reads `人物`
47 on the English UI too: it is their concept. `key` is never translated; it is the
48 model's token. The prompt lists `key` + `description`, `label` only when the
49 description is empty: `Person` beside `person` adds nothing and mixes scripts.
505. **LLM text for people takes `locale` from the request.** `reason` is generated when
51 someone clicks "Suggest with AI", so the caller states the language;
52 `label`/`description` in the same call follow `kb.ontology_lang`. `lang_name()` sends
53 `Chinese` rather than `zh`; the cold-start path passes `en`.
546. **Extracted data stays verbatim.** An entity is `张三` because paragraph 3 says so;
55 translating it breaks the evidence match, splits one person across Chinese and English
56 documents, and empties `surface_predicate`. Provenance has no switch.
57
58## Dead ends
59
60- **UI language as a deployment-level admin setting**, "like the concurrency limit". That
61 limit describes the deployment; the UI language describes the reader. A setting lives
62 with whatever it describes.
63- **A Chinese rewrite of the built-in ontology** (9 classes, 14 relations, negative
64 examples included) lost its object when seeding was removed (#125, #128,
65 [0009](0009-no-type-is-a-type.md), [0010](0010-no-relation-is-no-relation.md)). A
66 Chinese knowledge base now starts from an all-English pack; `ontology_lang = zh` affects
67 only terms the LLM proposes later. What remains is an imported vocabulary or packs with
68 Chinese labels ([0008](0008-ontology-packs-as-cold-start.md), open question).
69
70## Revisions
71
72- 2026-09-02: "guess `navigator.language` once" was never shipped, deliberately:
73 `detect()` reads `localStorage` and otherwise returns `"en"`, because the Chinese bundle
74 trails the English one and untranslated lines fall back silently. The line goes back in
75 when the bundle catches up.
76- 2026-09-02: since #112 `suggest` writes `ontology_proposals`
77 ([0003](0003-ontology-growth-loop.md)); the language conclusion is unchanged.
78
79## Open questions
80
81- **Bundle drift**: `typeof S` catches a missing key but not "the English wording changed
82 and the Chinese did not". Edit both together.
83- **Mixed-language corpora in one knowledge base**: one language per KB; design it when it
84 happens.