{{ message }}
feat: mirror source directory tree in batch translation output#1148
Open
rudi193-cmd wants to merge 1 commit into
Open
feat: mirror source directory tree in batch translation output#1148rudi193-cmd wants to merge 1 commit into
rudi193-cmd wants to merge 1 commit into
Conversation
When translating a directory with --dir, output files now reflect the source folder hierarchy instead of flattening everything into one level. Adds source_dir field to TranslateRequest and threads it through LegacyKernel → high_level.translate() → per-file subdir creation. Closes PDFMathTranslate#793
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Closes #793.
When
--diris used, translated files now land in a subdirectory structure that mirrors the source tree instead of being flattened into the output root.Example:
With
pdf2zh --dir docs/ -o out/you now get:What changed
TranslateRequest(kernel/protocol.py): addedsource_dir: Optional[str] = NonefieldLegacyKernel.translate()(kernel/legacy.py): passessource_dirthrough tohigh_level.translate()when sethigh_level.translate()(high_level.py): acceptssource_dirkwarg; computes a relative output subdir per file usingos.path.relpath, creates it withmkdir(parents=True), skips the logic for URL inputsmain()(pdf2zh.py): capturessource_dir = os.path.abspath(files[0])before expanding the file list, passes it intoTranslateRequestURL inputs and non-
--dirinvocations are unaffected — they continue writing directly toPath(output).Test plan
pdf2zh --dir /path/to/nested/ -o /tmp/out/— verify output mirrors source hierarchypdf2zh paper.pdf -o /tmp/out/— verify flat output unchangedpdf2zh https://…/paper.pdf -o /tmp/out/) — verify flat output unchanged