| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat(site): add an opt-in machine-translation tier for unbuilt languages (#822) * fix(figures): rebuild the stale chapter 8 artwork in 11 editions Commit 04c0ed70 replaced all five Chinese chapter-8 figures when the chapter was reorganized around continual evolution. Only book-ko, added afterwards, picked them up; every other edition still shipped the pre-reorganization artwork, so the captions described the new chapter while the pictures showed the old one. In book-en, book-ar and book-zhtw fig8-3 was additionally still untranslated Simplified Chinese, and book-es/ja/tr carried a further two-figure offset whose fig8-3/fig8-4 showed chapter-4 material. Rebuilds fig8-1..fig8-5 for all 11 affected editions from the current Chinese geometry, translating text nodes only so the drawings stay identical, and drops the orphaned fig8-6/fig8-7 left in book-es, book-ja and book-tr. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat(site): add an opt-in machine-translation tier for unbuilt languages The book ships 13 reviewed editions as static pages. This adds a clearly labelled tier 3 for the languages we do not build: the reader picks one from a separate "机器翻译" group in the language menu, and translate.js (https://github.com/xnx3/translate, MIT) rewrites the page's text nodes in the browser. The tier is deliberately constrained, because it is strictly worse than a built edition and must not be mistaken for one: * Opt-in and lazy. The third-party script is fetched only after the reader chooses one of these languages — a page view in a real edition makes no request to it. Pinned to a version and loaded with an SRI hash. * Always labelled. A notice sits above the content for as long as the tier is active and states what is not translated, with a "Turn off" control. * Translated from the English edition rather than the Chinese one: MT quality out of English is better for most targets and that edition is reviewed, so selecting a tier-3 language routes to the English page first. * Never indexed. It runs client-side only, so crawlers receive the untouched English source and no machine-translated text enters search results. Figures stay in English: they are <img src="…svg">, a separate document that page scripts cannot reach. Code blocks are left alone too — translate.js ignores <pre>/<code> by default, and this adds MathJax, Mermaid, the code block wrapper and the repo name to the ignore lists. lang-switcher.js gains a two-method window.langSwitcher export so the new script can map the current page to its English counterpart without duplicating the URL rules. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> | 2 个月前 | |
perf(site): split the search index per book edition (#821) * fix(figures): close Chinese numbering gaps and rebuild fig8-1 The Chinese source had reader-visible figure numbering gaps left behind by earlier content removals, and the caption number no longer matched the filename in two chapters. - ch5: restore the 图5-4 embed dropped by d39b1d74 while its prose reference survived, closing the 5-3 -> 5-5 gap. - ch7: retire the two figures the chapter dropped to descriptive names and shift fig7-18/19/20 down so caption number == filename again. - ch10: renumber 10-3..10-13 to 10-2..10-11 across all 13 editions, closing the gaps at 10-2 and 10-10; retire the two removed figures to descriptive names. Drop the dangling "Figure 10-10" reference in the English edition. - Rebuild fig8-1 for the 11 editions still shipping the pre-04c0ed70 artwork. The Chinese source now has gapless, filename-aligned numbering in every chapter with no dangling cross-references. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * perf(site): split the search index per book edition MkDocs' search plugin emits one search_index.json for the whole build. With 13 editions plus the ~94 companion-experiment pages in a single build that file had reached 55 MB, and Material fetches it in full the first time a reader opens search — so everyone downloaded the prose of 12 editions they cannot read. Split it into one file per edition. Each keeps the shared, language-agnostic experiment pages, so search from any edition still reaches the experiments exactly as before; only the other editions' prose is dropped. 55 MB -> 12-15 MB per edition (measured on the current build) scripts/split_search_index.py runs after the search plugin (MkDocs appends hooks: to the plugin list) and rewrites search/ into: search/search_index.json default edition + shared pages search/search_index.<slug>.json one per edition, slug = URL directory Keeping the default edition at the canonical filename means a client that never runs the router — or a stale cached page — degrades to today's behaviour instead of losing search. extras/search-index-router.js picks the matching file in the browser. Material builds the index URL as new URL("search/search_index.json", config.base) and requests it over XMLHttpRequest during bundle.js init; there is no config seam for the path, and extra_javascript loads after bundle.js, so overrides/main.html injects the router in the config block that base.html renders immediately before the bundle. Cross-edition navigation already forces a full reload (lang-switcher.js), so an instant-navigation page swap can never leave a reader on an index for the wrong edition. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> | 2 个月前 |