Repository navigation
Align built-in pretranslation with API path - #4606
Open
baha-bouali wants to merge 2 commits into
Open
baha-bouali wants to merge 2 commits into
baha-bouali wants to merge 2 commits into
Conversation
Contributor
Author
|
A small note aside This one took me roughly three weeks. Most of that time went into reading the code and studying the possible solutions. That was intentional: I wanted a deeper understanding of how pretranslation, uploads and the translation data fit together, and I got it. |
Collaborator
|
Thanks @baha-bouali — the structure matches what we agreed, and the converted match correctly keeps its original author. I'll wait for you to address the outcomes of our discussion before digging deeper. |
This branch has not been deployed
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.
Fixes #4526
What changed
Following the points agreed in the issue, the built-in pretranslation now follows the
same rules as the pretranslation upload API.
Behavior
Strings with unreviewed suggestions are pretranslated. A suggestion matching the
pretranslation becomes the pretranslation and keeps its author; other suggestions are
kept, only deactivated.
Fuzzy translations and older, different pretranslations are rejected and replaced; a
matching one is converted instead.
Strings with an approved translation are skipped, before calling machine translation.
A pretranslation that still fails checks after the retry with preserved placeables is
not stored.
Strings whose pretranslation was rejected are still never pretranslated again, and
Translate Toolkit checks stay disabled.
Structure
decide_pretranslation()(insync/upload.py) holds the decision both paths share.reject_translations()is a shared helper for rejecting and logging.The built-in path has its own write,
write_pretranslations(), since it differs fromthe API: bot authors, per-resource stats and latest translation, no check results to
store, and dropping strings instead of raising.
Writes happen in order: reject → deactivate → update → create, so a string never has
two active translations.
Choices
Those still need your confirmation:
automatic rejections don't count against pretranslation quality.
lock_import_target(), so it waits for an upload of thesame strings instead of colliding with it.
bulk_run_checks()is gone: everything stored has passed all checks, and the stalewarnings and errors of converted suggestions are deleted.
suggestion can be months old.
Docs
With these changes, two docs no longer described the behavior correctly, so I
updated
docs/dev/api.mdanddocs/admin/managing-pretranslation.mdto match.Tests
This is a draft, and new tests will follow.