Map saved Auto-Translate languages across providers - #154
Draft
Blackspirits wants to merge 1 commit into
Draft
Blackspirits wants to merge 1 commit into
Blackspirits wants to merge 1 commit into
Conversation
Blackspirits
commented
Sep 16, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Final adversarial review on 0a60681a76f9ec7061bee3163133b0374c137afd after CI SubtitleEdit#312: no blocker found. Rechecked NLLB/Google/LLM source and target restoration, underscore/hyphen script identifiers, ISO-639-3 prefix conversion, English-name preference and ambiguous multi-variant fail-closed behavior. The fallback now returns a code belonging to the current provider rather than a stale previous-provider identifier. All eight warnings are outside the changed set; upstream is still exactly the audited base dda1fce8.... No merge/promotion performed.
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.
Purpose
Current-main follow-up to the Auto-Translate changes merged in upstream commit
dda1fce8f9d4a605b1b6732acc072c7109dc6323(SubtitleEdit#14956 follow-ups).The upstream change improved source-language fallback by using the last selected source when language detection cannot identify a tiny/ambiguous selection. This audit found one cross-provider gap: the saved language identifier belongs to the provider that wrote it, but providers use incompatible identifier schemes.
Examples:
eng_Latn,deu_Latn,zho_Hans;en,de,zh-CN;English/German, with separate ISO metadata.Current upstream main was rechecked at
dda1fce8f9d4a605b1b6732acc072c7109dc6323, exactly this PR's base.Finding fixed
When detection returned no source language,
EvaluateDefaultSourceLanguageCode()returnedAutoTranslateLastSourceverbatim.If the previous engine was NLLB and the current engine was Google/Gemini/ChatGPT, a saved code such as
eng_Latndid not exist in the current source list.UpdateSourceLanguages()then failed every lookup and silently selectedSourceLanguages[0].The same identifier mismatch also affected
FindDefaultTargetLanguage(): a saved NLLB target such asdeu_Latncould not be restored by an LLM provider, so the target fell through to UI-language/default candidates instead of the user's last choice.Fix
The shared
FindLanguage()resolver now handles provider identifier differences in fail-safe order:zho_Hans==zho-Hans);eng->en,deu->de);Ambiguous multi-variant mappings are not guessed.
When source detection fails, the last saved source is first resolved through this current-engine mapping. The returned value is therefore the current engine's code, not a stale code copied from another provider. If no safe mapping exists, the existing English fallback remains.
Regression coverage
Tests pin three real cross-provider cases:
eng_Latnmaps to Googleen;deu_Latnmaps to GeminiGerman;zho_Hanspreserves Gemini's Chinese (Simplified) variant across underscore/hyphen conventions.Existing detectable-source and same-provider fallback tests remain unchanged.
Scope / branch state
dda1fce8f9d4a605b1b6732acc072c7109dc63230a60681a76f9ec7061bee3163133b0374c137afdAcceptance
AI assistance: ChatGPT was used for adversarial provider-language state review, NLLB/Google/LLM identifier comparison, fail-safe mapping design and regression coverage.
Final CI
Authoritative run: SubtitleEdit#312 on
0a60681a76f9ec7061bee3163133b0374c137afdAll eight warnings are outside the two-file #154 changed set.
Final drift gate
Upstream main was rechecked at
dda1fce8f9d4a605b1b6732acc072c7109dc6323, exactly the base of this PR. No post-base drift exists.Final adversarial review was performed on this exact HEAD after CI; no blocker found.