Brickheart

Handover translation plan

: Written by a human with AI assistance.

"i found the key, English, blank translation works wellin VS code autocomplete. processing the files can drop the en after getting them back"

Your answer fits what the engine already does: mergeInbox takes the English from the current source, not from the returned file, and the store keeps only text. A translator can delete the en line or leave it. Keep the hash line, because that's how stale translations are detected. Also delete the two untracked files from the LFS idea: rm app/lfs.mjs app/lfs.test.mjs.

Design

One shared engine, per-workspace inputs.

  • Engine: the logic in site/translate.mjs, plus uiFor and hashOf, moves to shared/engine/i18n.mjs. Its tests move to shared/engine/i18n.test.mjs, which the existing glob already runs.
  • Markdown-only code stays in site/: splitBlocks, applyBlocks and localizePages.
  • Per-language files: the engine's pure functions barely change. runTranslationStep loops over languages, reading and writing <dir>/<lang>.json (hash to text) and <dir>/todo.<lang>.json (the same key, hash, en, blank shape you like, one language per file).
  • Layout:
    • site/i18n/ui/ and site/i18n/content/
    • app/i18n/ui/
    • shared/languages.json
    • shared/project.json (siteName, baseUrl, sourceFolder), so the app stops importing site/config.mjs
  • File names: en.json is the English source, keyed by key. <lang>.json is hash-keyed on purpose, so an edited English string drops its old translation instead of keeping a stale one.
  • Gating: each workspace builds a language when its own UI strings are translated. The 22 nav.* keys stop blocking the app.
  • Migration: a one-time script splits ui.json into the site and app English files. It seeds the app's zh.json from the existing site store by hash, so no existing translation is lost.

Two risks in your data

  1. The zh Browse page could disappear. Today render-build.mjs has about 108 English strings outside ui.json. Once they become real keys, zh stops building in the app until they're translated, which would drop the live zh Browse page. So I'll keep the app changes local and unpushed until app/i18n/ui/todo.zh.json is filled and merged. The build warns you with the count. An alternative is per-page gating (Browse and Build gated separately), which is more code.
  2. Worker build triggers. You said each Worker only builds when its own folder changes. The app already imports site/config.mjs, site/ui.json and the site's translation files, so a site-only translation change wouldn't rebuild the app today. After the split the app depends only on app/ and shared/. Each Worker's watch paths must include shared/** in the dashboard (Settings, Builds). Please check that they do.

Commit plan

  1. Engine move. No behavior change, tests move with the code.
  2. Per-language files, ui/content split and migration script. The migration script is a one-off and can be deleted afterwards.
  3. The app's own i18n.
    • renderBuild reads from app/i18n/ui/en.json with no inline defaults.
    • The Build page is rendered for every built language, which fixes the offline /zh/build/ gap.
    • A new test checks that every t('...') key used in app/src and the renderers exists in the app's English file.
  4. Later: a contributor download page, CI-generated templates, and the settings page.

Data I need

rm app/lfs.mjs app/lfs.test.mjs
sed -n 1,12p site/blocks.mjs
grep -n "import\|^export" site/config.mjs
cat scripts/build-sitemap.mjs
cat .gitignore
grep -ohE "\bt\('[^']+'|\bt\(\`[^\`]+\`" app/src/main.ts app/src/build.ts app/src/attach-ui.ts | sort -u
grep -rn "ui-strings" app/src
node -e "const s=require('./site/translations/translations.json');console.log(Object.fromEntries(Object.entries(s).map(([l,v])=>[l,Object.keys(v).length])))"
git log --oneline -3

sed -n 1,12p site/blocks.mjs is for hashOf, which I haven't seen. The grep -ohE line lists the keys the browser scripts use, to catch any that aren't in the defaults. Paste the output and I'll write commit 1 in full.

Decisions already made

  • Contributor file: key, hash, en, blank translation. mergeInbox already takes English from the current source, so en is ignored on merge. Keep hash, because it detects stale translations.
  • Plain git, LFS parked. History rewrite after the stable release, with git filter-repo. Tag first. Keep its commit-map to fix the hashes cited in the blog and audit.
  • Delete app/lfs.mjs and app/lfs.test.mjs (untracked leftovers).
  • app/build.mjs 404 home is /<lang>/browse/. When /<lang>/index.html exists, change that one line.

Store and engine facts

  • Disk store: { zh: { "<hash of English>": { text } } }. keyView maps it to { key: { hash, text } }. Keys are page/N or ui/<key>.
  • completePages gates on all ui/* keys plus the page's blocks. The app currently gates on all 78 site ui.json keys via collectBlocks({}, ui).
  • uiFor(base, t) reads t['ui/<key>'].text.
  • todo.json is also the inbox. It is merged first, then rewritten, and deleted when empty. In CI the step only reads.
  • hashOf is in site/blocks.mjs; I never saw its source (line 6). Check it before moving it.

Key ownership (from ui.json and the renderers)

  • App uses: browse.* (23), table.noData, build.* (~108, currently inline defaults), skipLink, legoDisclaimer, notFoundTitle, notFoundText, notFoundHome.
  • Site only: nav.*, tagline, description, mainNavLabel, extraNavLabel, colour.*, table.colours.*, table.present, changeSettings, ldrawCredit, ldrawLicence, machineTranslated. The site's table placeholders read these through hydrate's U().
  • Duplicate in both files: skipLink, legoDisclaimer, notFound*.
  • Unknown: whether the app needs changeSettings (check app/render*.mjs). build.btn.*, build.att.* and build.collide.* keys are used but their lines were cut off. Take the full list from DEFAULTS plus grep -o "t('[^']*'".

Things to update when files move

  • scripts/build-sitemap.mjs reads site/languages.json directly.
  • app/build.mjs has STORE_FILE, imports site/config.mjs, and has the "languages.json has no..." error message.
  • site/build.mjs has translations dir, cfg.sourceFolder, and the same error message.
  • .gitignore has site/translations/todo.json. Change it to a per-language pattern.
  • site/config.mjs has siteName, baseUrl and sourceFolder. These go to shared/project.json. It also imports '../site/...' oddly, and nav.accessibility appears twice.
  • The existing tests (translate.test.mjs, localize.test.mjs, root.test.mjs) import config.mjs. Update the imports and keep the assertions.

Risks to check first

  1. Add the app's build.* keys, and zh Browse stops building until todo.zh.json is merged. Seed the app's zh store from the site store by hash. Keep this unpushed until merged.
  2. Each Worker's watch paths must include shared/**, or a shared change won't rebuild it.
  3. Confirm app/.test-build/ is gitignored - yes in /app gitignore file.
  4. Confirm the agent-api test is green after adding ValueError, NoMate and KeyError to CLASSES.

Data to bring to the new session

  • The updated audit.
  • The output of the data-gathering block from my last message. It includes blocks.mjs lines 1-12, grep import/export site/config.mjs, scripts/build-sitemap.mjs, .gitignore, the browser scripts' t() keys, grep ui-strings app/src, the store key counts, and git log -3.
  • A git status after the 404 and guard commits.