Skip to content

feat (kernel): experimental support for v2.0 using isolated environment#1102

Merged
reycn merged 2 commits intoPDFMathTranslate:mainfrom
reycn:main
Mar 22, 2026
Merged

feat (kernel): experimental support for v2.0 using isolated environment#1102
reycn merged 2 commits intoPDFMathTranslate:mainfrom
reycn:main

Conversation

@reycn
Copy link
Copy Markdown
Collaborator

@reycn reycn commented Mar 22, 2026

English

This PR introduces an experimental kernel abstraction layer that enables PDFMathTranslate to support multiple translation backends (legacy
v1, precise, and the new v2.0) through a unified interface.

Commit 1 (e975dde): Adds PDFMathTranslate-next as a git submodule under pdf2zh/kernel/, pointing to the next-generation translation engine.

Commit 2 (84efe44): Implements the full kernel system:

  • Kernel protocol (TranslateRequest) and registry for switching between backends at runtime
  • LegacyKernel: wraps the existing v1 translate path
  • PreciseKernel: wraps the BabelDoc-based path
  • V2BridgeKernel: bridges to the v2.0 engine via an isolated subprocess with venv auto-provisioning (v2_worker.py)
  • GUI updated to use a mode selector dropdown instead of the old use_babeldoc checkbox
  • CLI (pdf2zh.py) gains --mode flag to select kernel
  • 703-line test suite covering registry, protocol, legacy/precise/v2 kernels, and worker lifecycle

中文

本 PR 引入了实验性的内核抽象层,使 PDFMathTranslate 能够通过统一接口支持多种翻译后端(legacy v1、precise 及全新的 v2.0)。

提交 1(e975dde):将 PDFMathTranslate-next 作为 git submodule 添加到 pdf2zh/kernel/ 下,指向下一代翻译引擎。

提交 2(84efe44):实现完整的内核系统:

  • 内核协议(TranslateRequest)与注册表,支持运行时切换后端
  • LegacyKernel:封装现有 v1 翻译路径
  • PreciseKernel:封装基于 BabelDoc 的翻译路径
  • V2BridgeKernel:通过隔离子进程桥接 v2.0 引擎,自动创建 venv 环境(v2_worker.py)
  • GUI 将原有的 use_babeldoc 复选框替换为模式选择下拉菜单
  • CLI(pdf2zh.py)新增 --mode 参数用于选择内核
  • 703 行测试套件,覆盖注册表、协议、legacy/precise/v2 内核及 worker 生命周期

@reycn reycn merged commit a0a313b into PDFMathTranslate:main Mar 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant