Repository navigation
fix: compare unchanged translation against translate_input.unicode - #621
Closed
Morningstar202604 wants to merge 1 commit into
Closed
Morningstar202604 wants to merge 1 commit into
Morningstar202604 wants to merge 1 commit into
Conversation
post_translate_paragraph compared the translated string with the TranslateInput object itself, so the unchanged-output branch could never be taken: even when the translator returns translate_input.unicode verbatim, the paragraph was re-typeset and its original layout objects were dropped. Compare against the string payload instead. Ref: funstory-ai#610
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.
post_translate_paragraphcompares the translated string with theTranslateInputobject:A
strnever equals aTranslateInput, so the unchanged-output branch is unreachable even when the translator returnstranslate_input.unicodeverbatim. The paragraph is then re-typeset throughparse_translate_output, dropping its original layout objects, andset_placeholder_full_match()is never called on the LLM tracker.This is the direct type mismatch described in #610.
Fix: compare against the string payload (
translate_input.unicode), consistent with the surrounding code in the same file (pre_translate_paragraphsetstext = translate_input.unicode).Verification — extracted
TranslateInputandpost_translate_paragraphfrom the patched file and ran both conditions against a stub tracker/paragraph:True, layout rebuilt (the unreachable-branch bug)False, layout preservedTrue(unchanged behaviour)ruff check,ruff format --checkandpy_compilepass on the modified file.Refs #610
Summary by cubic
Fixes the unchanged-output branch in
post_translate_paragraphso verbatim translations preserve the original layout instead of being re-typeset.Previously the branch compared a
stragainst aTranslateInputobject, so it was unreachable even when the translator returned the input unchanged. The comparison now targetstranslate_input.unicode, matching howpre_translate_paragraphextracts the string, which also lets the LLM tracker'sset_placeholder_full_match()fire correctly.Written for commit 62bc8e8. Summary will update on new commits.