Skip to content

Conversation

@Cycloctane
Copy link
Contributor

related issue: #731

@awwaawwa
Copy link
Collaborator

awwaawwa commented Mar 9, 2025

pdf2zh/gui.py has another one around line 400.

@Cycloctane Cycloctane marked this pull request as ready for review March 9, 2025 08:04
@awwaawwa awwaawwa requested a review from Copilot March 9, 2025 09:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds support for an option to ignore translation caching throughout the application. The changes include adding a new command‐line argument (--ignore-cache) in the docs, CLI parser, and README, propagating the option to the translator constructors (including GUI and converter modules), and updating tests to account for the new parameter.

Reviewed Changes

File Description
docs/ADVANCED.md Documents the new "Translation cache" section and the --ignore-cache option.
pdf2zh/pdf2zh.py Adds the --ignore-cache argument to the parser and passes it to the translator.
pdf2zh/gui.py Updates GUI functions to support and forward the ignore_cache option.
pdf2zh/translator.py Modifies BaseTranslator and its subclasses to accept an ignore_cache parameter.
README.md Documents the new command-line option in the usage table.
pdf2zh/high_level.py Propagates the ignore_cache flag to translation patch functions.
test/test_translator.py Updates translator instantiation in tests to include the new parameter.
pdf2zh/converter.py Passes the ignore_cache option from the converter to the translator.

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

test/test_translator.py:33

  • Consider adding tests that verify the behavior when ignore_cache is set to True, ensuring that the caching mechanism is bypassed as expected.
translator = AutoIncreaseTranslator("en", "zh", "test", False)

pdf2zh/translator.py:54

  • [nitpick] Consider providing a default value for the ignore_cache parameter (e.g. ignore_cache: bool = False) in BaseTranslator's constructor to reduce the impact on existing usages.
def __init__(self, lang_in: str, lang_out: str, model: str, ignore_cache: bool):

@awwaawwa awwaawwa self-requested a review March 9, 2025 10:26
@awwaawwa awwaawwa linked an issue Mar 9, 2025 that may be closed by this pull request
@awwaawwa awwaawwa merged commit 279baec into PDFMathTranslate:main Mar 11, 2025
7 checks passed
@awwaawwa
Copy link
Collaborator

Thank you for your contribution. According to https://funstory-ai.github.io/BabelDOC/CONTRIBUTOR_REWARD/ , you can apply for a monthly membership redemption code for Immersive Translate.

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.

feat(webui): 忽略翻译缓存并强制重新翻译

2 participants