BabelDOC 0.1.11__tar.gz → 0.1.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- babeldoc-0.1.12/.cursorignore +2 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.gitignore +5 -1
- {babeldoc-0.1.11 → babeldoc-0.1.12}/PKG-INFO +3 -1
- {babeldoc-0.1.11 → babeldoc-0.1.12}/README.md +2 -0
- babeldoc-0.1.12/babeldoc/__init__.py +1 -0
- babeldoc-0.1.12/babeldoc/const.py +28 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/backend/pdf_creater.py +112 -38
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/typesetting.py +2 -1
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/translator/cache.py +3 -3
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/main.py +14 -1
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/translation_config.py +2 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/pyproject.toml +5 -2
- {babeldoc-0.1.11 → babeldoc-0.1.12}/uv.lock +1 -1
- babeldoc-0.1.11/babeldoc/__init__.py +0 -1
- babeldoc-0.1.11/babeldoc/const.py +0 -7
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/dependabot.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/labels.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/release-drafter.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/workflows/docs.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.github/workflows/test.yml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/LICENSE +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/converter.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/backend/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/frontend/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/frontend/il_creater.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/il_version_1.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/il_version_1.rnc +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/il_version_1.rng +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/il_version_1.xsd +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/add_debug_information.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/il_translator.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/layout_parser.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/remove_descent.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/translator/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/translator/translator.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/utils/fontmap.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/utils/layout_helper.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/utils/style_helper.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/document_il/xml_converter.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/docvision/__init__.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/docvision/doclayout.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/docvision/rpc_doclayout.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/high_level.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/pdfinterp.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/babeldoc/progress_monitor.py +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/CONTRIBUTING.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/CONTRIBUTOR_REWARD.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/README.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/deploy.sh +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/images/babeldoc-banner.png +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/images/babeldoc-contributor_reward_example.png +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/index.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/intro-to-pdf-object.md +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/docs/requirements.txt +0 -0
- {babeldoc-0.1.11 → babeldoc-0.1.12}/mkdocs.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BabelDOC
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
4
4
|
Summary: Yet Another Document Translator
|
|
5
5
|
Project-URL: Homepage, https://github.com/funstory-ai/BabelDOC
|
|
6
6
|
Project-URL: Issues, https://github.com/funstory-ai/BabelDOC/issues
|
|
@@ -142,6 +142,8 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
|
|
|
142
142
|
- `--dual-translate-first`: Put translated pages first in dual PDF mode (default: original pages first)
|
|
143
143
|
- `--disable-rich-text-translate`: Disable rich text translation (may help improve compatibility with some PDFs)
|
|
144
144
|
- `--enhance-compatibility`: Enable all compatibility enhancement options (equivalent to --skip-clean --dual-translate-first --disable-rich-text-translate)
|
|
145
|
+
- `--use-side-by-side-dual`: Use side-by-side mode for dual PDF (default). Original and translated pages are shown side by side on the same page.
|
|
146
|
+
- `--use-alternating-pages-dual`: Use alternating pages mode for dual PDF. Original and translated pages are arranged in alternate order.
|
|
145
147
|
|
|
146
148
|
> [!TIP]
|
|
147
149
|
> - Both `--skip-clean` and `--dual-translate-first` may help improve compatibility with some PDF readers
|
|
@@ -110,6 +110,8 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
|
|
|
110
110
|
- `--dual-translate-first`: Put translated pages first in dual PDF mode (default: original pages first)
|
|
111
111
|
- `--disable-rich-text-translate`: Disable rich text translation (may help improve compatibility with some PDFs)
|
|
112
112
|
- `--enhance-compatibility`: Enable all compatibility enhancement options (equivalent to --skip-clean --dual-translate-first --disable-rich-text-translate)
|
|
113
|
+
- `--use-side-by-side-dual`: Use side-by-side mode for dual PDF (default). Original and translated pages are shown side by side on the same page.
|
|
114
|
+
- `--use-alternating-pages-dual`: Use alternating pages mode for dual PDF. Original and translated pages are arranged in alternate order.
|
|
113
115
|
|
|
114
116
|
> [!TIP]
|
|
115
117
|
> - Both `--skip-clean` and `--dual-translate-first` may help improve compatibility with some PDF readers
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.12"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import subprocess
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.12"
|
|
6
|
+
|
|
7
|
+
CACHE_FOLDER = Path.home() / ".cache" / "babeldoc"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_cache_file_path(filename):
|
|
11
|
+
return CACHE_FOLDER / filename
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
git_path = shutil.which("git")
|
|
16
|
+
if git_path is None:
|
|
17
|
+
raise FileNotFoundError("git executable not found")
|
|
18
|
+
|
|
19
|
+
WATERMARK_VERSION = (
|
|
20
|
+
subprocess.check_output( # noqa: S603
|
|
21
|
+
[git_path, "describe", "--always"],
|
|
22
|
+
cwd=Path(__file__).resolve().parent,
|
|
23
|
+
)
|
|
24
|
+
.strip()
|
|
25
|
+
.decode()
|
|
26
|
+
)
|
|
27
|
+
except (OSError, FileNotFoundError):
|
|
28
|
+
WATERMARK_VERSION = f"v{__version__}"
|
|
@@ -156,6 +156,100 @@ class PDFCreater:
|
|
|
156
156
|
# Restore graphics state
|
|
157
157
|
draw_op.append(b"Q\n")
|
|
158
158
|
|
|
159
|
+
def create_side_by_side_dual_pdf(
|
|
160
|
+
self,
|
|
161
|
+
original_pdf: pymupdf.Document,
|
|
162
|
+
translated_pdf: pymupdf.Document,
|
|
163
|
+
dual_out_path: str,
|
|
164
|
+
translation_config: TranslationConfig,
|
|
165
|
+
) -> pymupdf.Document:
|
|
166
|
+
"""Create a dual PDF with side-by-side pages (original and translation).
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
original_pdf: Original PDF document
|
|
170
|
+
translated_pdf: Translated PDF document
|
|
171
|
+
dual_out_path: Output path for the dual PDF
|
|
172
|
+
translation_config: Translation configuration
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
The created dual PDF document
|
|
176
|
+
"""
|
|
177
|
+
# Create a new PDF for side-by-side pages
|
|
178
|
+
dual = pymupdf.open()
|
|
179
|
+
page_count = min(original_pdf.page_count, translated_pdf.page_count)
|
|
180
|
+
|
|
181
|
+
for page_id in range(page_count):
|
|
182
|
+
# Get pages from both PDFs
|
|
183
|
+
orig_page = original_pdf[page_id]
|
|
184
|
+
trans_page = translated_pdf[page_id]
|
|
185
|
+
|
|
186
|
+
# Calculate total width and use max height
|
|
187
|
+
total_width = orig_page.rect.width + trans_page.rect.width
|
|
188
|
+
max_height = max(orig_page.rect.height, trans_page.rect.height)
|
|
189
|
+
|
|
190
|
+
# Create new page with combined width
|
|
191
|
+
dual_page = dual.new_page(width=total_width, height=max_height)
|
|
192
|
+
|
|
193
|
+
# Define rectangles for left and right sides
|
|
194
|
+
left_width = (
|
|
195
|
+
orig_page.rect.width
|
|
196
|
+
if not translation_config.dual_translate_first
|
|
197
|
+
else trans_page.rect.width
|
|
198
|
+
)
|
|
199
|
+
rect_left = pymupdf.Rect(0, 0, left_width, max_height)
|
|
200
|
+
rect_right = pymupdf.Rect(left_width, 0, total_width, max_height)
|
|
201
|
+
|
|
202
|
+
# Show pages according to dual_translate_first setting
|
|
203
|
+
if translation_config.dual_translate_first:
|
|
204
|
+
# Show translated page on left and original on right
|
|
205
|
+
rect_left, rect_right = rect_right, rect_left
|
|
206
|
+
|
|
207
|
+
# Show original page on left and translated on right (default)
|
|
208
|
+
dual_page.show_pdf_page(
|
|
209
|
+
rect_left,
|
|
210
|
+
original_pdf,
|
|
211
|
+
page_id,
|
|
212
|
+
keep_proportion=True,
|
|
213
|
+
)
|
|
214
|
+
dual_page.show_pdf_page(
|
|
215
|
+
rect_right,
|
|
216
|
+
translated_pdf,
|
|
217
|
+
page_id,
|
|
218
|
+
keep_proportion=True,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
return dual
|
|
222
|
+
|
|
223
|
+
def create_alternating_pages_dual_pdf(
|
|
224
|
+
self,
|
|
225
|
+
original_pdf_path: str,
|
|
226
|
+
translated_pdf: pymupdf.Document,
|
|
227
|
+
translation_config: TranslationConfig,
|
|
228
|
+
) -> pymupdf.Document:
|
|
229
|
+
"""Create a dual PDF with alternating pages (original and translation).
|
|
230
|
+
|
|
231
|
+
Args:
|
|
232
|
+
original_pdf_path: Path to the original PDF
|
|
233
|
+
translated_pdf: Translated PDF document
|
|
234
|
+
translation_config: Translation configuration
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
The created dual PDF document
|
|
238
|
+
"""
|
|
239
|
+
# Open the original PDF and insert translated PDF
|
|
240
|
+
dual = pymupdf.open(original_pdf_path)
|
|
241
|
+
dual.insert_file(translated_pdf)
|
|
242
|
+
|
|
243
|
+
# Rearrange pages to alternate between original and translated
|
|
244
|
+
page_count = translated_pdf.page_count
|
|
245
|
+
for page_id in range(page_count):
|
|
246
|
+
if translation_config.dual_translate_first:
|
|
247
|
+
dual.move_page(page_count + page_id, page_id * 2)
|
|
248
|
+
else:
|
|
249
|
+
dual.move_page(page_count + page_id, page_id * 2 + 1)
|
|
250
|
+
|
|
251
|
+
return dual
|
|
252
|
+
|
|
159
253
|
def write_debug_info(
|
|
160
254
|
self,
|
|
161
255
|
pdf: pymupdf.Document,
|
|
@@ -388,48 +482,28 @@ class PDFCreater:
|
|
|
388
482
|
original_pdf = pymupdf.open(self.original_pdf_path)
|
|
389
483
|
translated_pdf = pdf
|
|
390
484
|
|
|
391
|
-
#
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
trans_page = translated_pdf[page_id]
|
|
399
|
-
|
|
400
|
-
# Calculate total width and use max height
|
|
401
|
-
total_width = orig_page.rect.width + trans_page.rect.width
|
|
402
|
-
max_height = max(orig_page.rect.height, trans_page.rect.height)
|
|
403
|
-
|
|
404
|
-
# Create new page with combined width
|
|
405
|
-
dual_page = dual.new_page(width=total_width, height=max_height)
|
|
406
|
-
|
|
407
|
-
# Define rectangles for left and right sides
|
|
408
|
-
left_width = (
|
|
409
|
-
orig_page.rect.width
|
|
410
|
-
if not translation_config.dual_translate_first
|
|
411
|
-
else trans_page.rect.width
|
|
412
|
-
)
|
|
413
|
-
rect_left = pymupdf.Rect(0, 0, left_width, max_height)
|
|
414
|
-
rect_right = pymupdf.Rect(left_width, 0, total_width, max_height)
|
|
415
|
-
|
|
416
|
-
# Show pages according to dual_translate_first setting
|
|
417
|
-
if translation_config.dual_translate_first:
|
|
418
|
-
# Show translated page on left and original on right
|
|
419
|
-
rect_left, rect_right = rect_right, rect_left
|
|
485
|
+
# Choose between side-by-side and alternating pages format
|
|
486
|
+
# Default to side-by-side if not specified
|
|
487
|
+
use_side_by_side = getattr(
|
|
488
|
+
translation_config,
|
|
489
|
+
"use_side_by_side_dual",
|
|
490
|
+
True,
|
|
491
|
+
)
|
|
420
492
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
493
|
+
if use_side_by_side:
|
|
494
|
+
# Create a dual PDF with side-by-side pages (original and translation)
|
|
495
|
+
dual = self.create_side_by_side_dual_pdf(
|
|
424
496
|
original_pdf,
|
|
425
|
-
|
|
426
|
-
|
|
497
|
+
translated_pdf,
|
|
498
|
+
dual_out_path,
|
|
499
|
+
translation_config,
|
|
427
500
|
)
|
|
428
|
-
|
|
429
|
-
|
|
501
|
+
else:
|
|
502
|
+
# Create a dual PDF with alternating pages (original and translation)
|
|
503
|
+
dual = self.create_alternating_pages_dual_pdf(
|
|
504
|
+
self.original_pdf_path,
|
|
430
505
|
translated_pdf,
|
|
431
|
-
|
|
432
|
-
keep_proportion=True,
|
|
506
|
+
translation_config,
|
|
433
507
|
)
|
|
434
508
|
|
|
435
509
|
if translation_config.debug:
|
|
@@ -5,6 +5,7 @@ from functools import cache
|
|
|
5
5
|
|
|
6
6
|
import pymupdf
|
|
7
7
|
|
|
8
|
+
from babeldoc.const import WATERMARK_VERSION
|
|
8
9
|
from babeldoc.document_il import Box
|
|
9
10
|
from babeldoc.document_il import PdfCharacter
|
|
10
11
|
from babeldoc.document_il import PdfFormula
|
|
@@ -397,7 +398,7 @@ class Typesetting:
|
|
|
397
398
|
font_size=6,
|
|
398
399
|
graphic_state=il_version_1.GraphicState(),
|
|
399
400
|
)
|
|
400
|
-
text = "本文档由funstory.ai的开源PDF翻译库BabelDOC(http://yadt.io)翻译,本仓库正在积极的建设当中,欢迎star和关注。"
|
|
401
|
+
text = f"本文档由funstory.ai的开源PDF翻译库BabelDOC {WATERMARK_VERSION} (http://yadt.io)翻译,本仓库正在积极的建设当中,欢迎star和关注。"
|
|
401
402
|
if self.translation_config.debug:
|
|
402
403
|
text += "\n 当前为DEBUG模式,将显示更多辅助信息。请注意,部分框的位置对应原文,但在译文中可能不正确。"
|
|
403
404
|
page.pdf_paragraph.append(
|
|
@@ -8,7 +8,7 @@ from peewee import Model
|
|
|
8
8
|
from peewee import SqliteDatabase
|
|
9
9
|
from peewee import TextField
|
|
10
10
|
|
|
11
|
-
from babeldoc.const import CACHE_FOLDER
|
|
11
|
+
from babeldoc.const import CACHE_FOLDER
|
|
12
12
|
|
|
13
13
|
# we don't init the database here
|
|
14
14
|
db = SqliteDatabase(None)
|
|
@@ -94,9 +94,9 @@ class TranslationCache:
|
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
def init_db(remove_exists=False):
|
|
97
|
-
|
|
97
|
+
CACHE_FOLDER.mkdir(parents=True, exist_ok=True)
|
|
98
98
|
# The current version does not support database migration, so add the version number to the file name.
|
|
99
|
-
cache_db_path =
|
|
99
|
+
cache_db_path = CACHE_FOLDER / "cache.v1.db"
|
|
100
100
|
if remove_exists and cache_db_path.exists():
|
|
101
101
|
cache_db_path.unlink()
|
|
102
102
|
db.init(
|
|
@@ -20,7 +20,7 @@ from babeldoc.document_il.translator.translator import set_translate_rate_limite
|
|
|
20
20
|
from babeldoc.translation_config import TranslationConfig
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
|
-
__version__ = "0.1.
|
|
23
|
+
__version__ = "0.1.12"
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def create_parser():
|
|
@@ -176,6 +176,18 @@ def create_parser():
|
|
|
176
176
|
action="store_true",
|
|
177
177
|
help="Enable all compatibility enhancement options (equivalent to --skip-clean --dual-translate-first --disable-rich-text-translate)",
|
|
178
178
|
)
|
|
179
|
+
translation_params.add_argument(
|
|
180
|
+
"--use-side-by-side-dual",
|
|
181
|
+
default=True,
|
|
182
|
+
action="store_true",
|
|
183
|
+
help="Use side-by-side mode for dual PDF (default). When enabled, original and translated pages are shown side by side.",
|
|
184
|
+
)
|
|
185
|
+
translation_params.add_argument(
|
|
186
|
+
"--use-alternating-pages-dual",
|
|
187
|
+
dest="use_side_by_side_dual",
|
|
188
|
+
action="store_false",
|
|
189
|
+
help="Use alternating pages mode for dual PDF. When enabled, original and translated pages are arranged in alternate order.",
|
|
190
|
+
)
|
|
179
191
|
translation_params.add_argument(
|
|
180
192
|
"--report-interval",
|
|
181
193
|
type=float,
|
|
@@ -426,6 +438,7 @@ async def main():
|
|
|
426
438
|
dual_translate_first=args.dual_translate_first,
|
|
427
439
|
disable_rich_text_translate=args.disable_rich_text_translate,
|
|
428
440
|
enhance_compatibility=args.enhance_compatibility,
|
|
441
|
+
use_side_by_side_dual=args.use_side_by_side_dual,
|
|
429
442
|
report_interval=args.report_interval,
|
|
430
443
|
min_text_length=args.min_text_length,
|
|
431
444
|
)
|
|
@@ -37,6 +37,7 @@ class TranslationConfig:
|
|
|
37
37
|
enhance_compatibility: bool = False, # 增强兼容性模式
|
|
38
38
|
report_interval: float = 0.1, # Progress report interval in seconds
|
|
39
39
|
min_text_length: int = 5, # Minimum text length to translate
|
|
40
|
+
use_side_by_side_dual: bool = True, # 是否使用拼版式双语PDF(并排显示原文和译文)
|
|
40
41
|
):
|
|
41
42
|
self.input_file = input_file
|
|
42
43
|
self.translator = translator
|
|
@@ -62,6 +63,7 @@ class TranslationConfig:
|
|
|
62
63
|
)
|
|
63
64
|
self.report_interval = report_interval
|
|
64
65
|
self.min_text_length = min_text_length
|
|
66
|
+
self.use_side_by_side_dual = use_side_by_side_dual
|
|
65
67
|
if progress_monitor:
|
|
66
68
|
if progress_monitor.cancel_event is None:
|
|
67
69
|
progress_monitor.cancel_event = threading.Event()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "BabelDOC"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.12"
|
|
4
4
|
description = "Yet Another Document Translator"
|
|
5
5
|
license = "AGPL-3.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -124,7 +124,7 @@ dev = [
|
|
|
124
124
|
]
|
|
125
125
|
|
|
126
126
|
[bumpver]
|
|
127
|
-
current_version = "0.1.
|
|
127
|
+
current_version = "0.1.12"
|
|
128
128
|
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
|
129
129
|
|
|
130
130
|
[bumpver.file_patterns]
|
|
@@ -138,3 +138,6 @@ version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
|
|
138
138
|
"babeldoc/main.py" = [
|
|
139
139
|
'__version__ = "{version}"'
|
|
140
140
|
]
|
|
141
|
+
"babeldoc/const.py" = [
|
|
142
|
+
'__version__ = "{version}"'
|
|
143
|
+
]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.11"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.1.11 → babeldoc-0.1.12}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|