Handover translation plan
"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, plusuiForandhashOf, moves toshared/engine/i18n.mjs. Its tests move toshared/engine/i18n.test.mjs, which the existing glob already runs. - Markdown-only code stays in
site/:splitBlocks,applyBlocksandlocalizePages. - Per-language files: the engine's pure functions barely change.
runTranslationSteploops 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/andsite/i18n/content/app/i18n/ui/shared/languages.jsonshared/project.json(siteName,baseUrl,sourceFolder), so the app stops importingsite/config.mjs
- File names:
en.jsonis the English source, keyed by key.<lang>.jsonis 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.jsoninto the site and app English files. It seeds the app'szh.jsonfrom the existing site store by hash, so no existing translation is lost.
Two risks in your data
- The
zhBrowse page could disappear. Todayrender-build.mjshas about 108 English strings outsideui.json. Once they become real keys,zhstops building in the app until they're translated, which would drop the livezhBrowse page. So I'll keep the app changes local and unpushed untilapp/i18n/ui/todo.zh.jsonis 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. - Worker build triggers. You said each Worker only builds when its own folder changes. The app already imports
site/config.mjs,site/ui.jsonand the site's translation files, so a site-only translation change wouldn't rebuild the app today. After the split the app depends only onapp/andshared/. Each Worker's watch paths must includeshared/**in the dashboard (Settings, Builds). Please check that they do.
Commit plan
- Engine move. No behavior change, tests move with the code.
- Per-language files, ui/content split and migration script. The migration script is a one-off and can be deleted afterwards.
- The app's own i18n.
renderBuildreads fromapp/i18n/ui/en.jsonwith 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 inapp/srcand the renderers exists in the app's English file.
- 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.mergeInboxalready takes English from the current source, soenis ignored on merge. Keephash, 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.mjsandapp/lfs.test.mjs(untracked leftovers). app/build.mjs404homeis/<lang>/browse/. When/<lang>/index.htmlexists, change that one line.
Store and engine facts
- Disk store:
{ zh: { "<hash of English>": { text } } }.keyViewmaps it to{ key: { hash, text } }. Keys arepage/Norui/<key>. completePagesgates on allui/*keys plus the page's blocks. The app currently gates on all 78 siteui.jsonkeys viacollectBlocks({}, ui).uiFor(base, t)readst['ui/<key>'].text.todo.jsonis also the inbox. It is merged first, then rewritten, and deleted when empty. In CI the step only reads.hashOfis insite/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 throughhydrate'sU(). - Duplicate in both files:
skipLink,legoDisclaimer,notFound*. - Unknown: whether the app needs
changeSettings(checkapp/render*.mjs).build.btn.*,build.att.*andbuild.collide.*keys are used but their lines were cut off. Take the full list fromDEFAULTSplusgrep -o "t('[^']*'".
Things to update when files move
scripts/build-sitemap.mjsreadssite/languages.jsondirectly.app/build.mjshasSTORE_FILE, importssite/config.mjs, and has the "languages.json has no..." error message.site/build.mjshastranslationsdir,cfg.sourceFolder, and the same error message..gitignorehassite/translations/todo.json. Change it to a per-language pattern.site/config.mjshassiteName,baseUrlandsourceFolder. These go toshared/project.json. It also imports'../site/...'oddly, andnav.accessibilityappears twice.- The existing tests (
translate.test.mjs,localize.test.mjs,root.test.mjs) importconfig.mjs. Update the imports and keep the assertions.
Risks to check first
- Add the app's
build.*keys, andzhBrowse stops building untiltodo.zh.jsonis merged. Seed the app'szhstore from the site store by hash. Keep this unpushed until merged. - Each Worker's watch paths must include
shared/**, or a shared change won't rebuild it. - Confirm
app/.test-build/is gitignored - yes in /app gitignore file. - Confirm the
agent-apitest is green after addingValueError,NoMateandKeyErrortoCLASSES.
Data to bring to the new session
- The updated audit.
- The output of the data-gathering block from my last message. It includes
blocks.mjslines 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, andgit log -3. - A
git statusafter the 404 and guard commits.