Elffuss BraidHub

kikocis/utopia public

dev · 4.9 KiBSourceRawPermalink

0004 · Language follows the reader of each text

The problem

One language switch cannot serve five kinds of text with different readers and sources:

TextReaderSource
UI strings ("Import an ontology")peoplethe i18n bundle
Server errors ("Password must be at least 8 characters")peopleRust
Ontology label / descriptionthe model reads descriptionpacks, users, OWL import
LLM text generated on the spot (a suggested reason)peoplethe model, on demand
Extracted data (张三, surface_predicate "runs on")people and the modelthe document, verbatim

The last row is not copy. It is a quotation.

Decisions

  1. UI strings are a per-person client setting, like dark mode: a foreign colleague in a Chinese company should not need an administrator to see English. Kept in localStorage via makeStore, resolved in one function that everything else consumes. The Chinese bundle is const zh: typeof S = { … }: a missing key fails compilation, where Partial with fallback would leave a silently English line.
  2. Server errors become keys. With the locale in the client, any string left in Rust is permanently untranslatable. Errors a user can hit are AppError::Invalid with a code for the frontend err.* table (the English message stays for MCP, CLI and logs). API-contract guards (role must be admin, editor or viewer) stay English Validation: their reader is a developer. Hence a hard rule: the server produces no display text.
  3. Ontology description follows the corpus. It goes verbatim into the extraction prompt beside the documents, and Chinese UI with English class descriptions is common. So it is a knowledge-base property, knowledge_bases.ontology_lang, whose deployment default is named "default ontology language for new knowledge bases"; call it "system language" and someone will hang the UI language on it.
  4. label is data and follows no switch. A class a Chinese team named 人物 reads 人物 on the English UI too: it is their concept. key is never translated; it is the model's token. The prompt lists key + description, label only when the description is empty: Person beside person adds nothing and mixes scripts.
  5. LLM text for people takes locale from the request. reason is generated when someone clicks "Suggest with AI", so the caller states the language; label/description in the same call follow kb.ontology_lang. lang_name() sends Chinese rather than zh; the cold-start path passes en.
  6. Extracted data stays verbatim. An entity is 张三 because paragraph 3 says so; translating it breaks the evidence match, splits one person across Chinese and English documents, and empties surface_predicate. Provenance has no switch.

Dead ends

Revisions

Open questions