Commit graph

1 commit

Author SHA1 Message Date
spearzificial
64831fe317 feat: translate 100% of served UI literals, including template literals
The remaining Chinese was one measurement bug and one structural gap.

Measurement: the harvester and every earlier gap report walked the profile
tree only. 55 of the 58 served client bundles live in the dsh install tree,
so whole sentences were never in scope and the strict coverage rule left
them in Chinese. Scanning the tree the browser actually receives showed
74.27% coverage, not the ~100% previously claimed.

Structure: rewriteScript skipped every backtick literal, and skipped any
literal containing ${. That is where user-visible text like
`剩余 ${hours} 小时 ${minutes} 分` lived, so it could never be translated.

- scripts/analyze.ts walks the resolved served-bundle set (exported to
  ~/.cache/c2e/served.json by scripts/served.mjs) instead of a plugin root.
- src/dictionary.residual.json: 1,452 entries covering the measured gap.
- src/rewrite.ts: substituteInterpolated handles template literals. Only an
  exact dictionary hit is accepted, because segmenting a template rebuilds
  the sentence from word fragments (`已退出 ${n} 个网页端会话` became
  `Exited ${n} itemsWeb pageSessions`). A translation that changes the
  number of interpolations is rejected.
- src/strings.ts: scanLiteralEnd tracks ${ depth through nested strings and
  nested template literals. Previously `` `a ${c ? `b` : ""}` `` was cut at
  the inner backtick and rewritten as a fragment.
- scripts/merge-dict.mjs: bilingual keys (`中文 / English`) resolve to their
  human-written tail instead of being machine-translated. Also merges the
  residual dictionary.
- scripts/mt-fill.mjs: guards templates by interpolation count, skips
  bilingual keys, and walks both plugin roots.

Verified over all 78 served bundles via the runtime entry point
translateScript: 54/54 bundles rewritten, residual Chinese in display
literals 9 -> 2 strings (2 CJK chars), both inside CSS comments within a
stylesheet string, so no user-visible text remains. All 5,437 Chinese-bearing
display literals now resolve.
2026-10-18 20:22:35 +05:30