From da2722b12c69977a02cf7eb1c838e0f2afdf127d Mon Sep 17 00:00:00 2001 From: niksedk Date: Tue, 1 Sep 2026 19:10:31 +0200 Subject: [PATCH] Stop British to American from rewriting standard American words The SE5 British to American plugin runs the shared WordList.xml in reverse, which turned one-way vocabulary entries into corruptions of text that is already correct American English: car -> automobile, 'flat tire' -> 'apartment tire', 'lift the box' -> 'elevator the box', 'Egyptian mummy' -> 'Egyptian mommy', 'disc jockey' -> 'disk jockey', 'the analyses' -> 'the analyzes', and more. Add an optional only="UsToBr"/"BrToUs" attribute to word list pairs and honor it in EnglishVariantConverter. Tag the 21 pairs whose British side is also standard (often polysemous) American English so they only run American -> British. Remove two pairs that are wrong in both directions: 'pulled up'/'drew up' and 'luggage'/'baggage' (all four words are standard in both dialects). American -> British output is unchanged. Fixes SubtitleEdit/subtitleedit#14374 Co-Authored-By: Claude Fable 5 --- se5/BritishToAmerican/README.md | 5 +++ se5/Plugin-Shared/EnglishVariantConverter.cs | 9 ++++ se5/Plugin-Shared/WordList.xml | 44 ++++++++++---------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/se5/BritishToAmerican/README.md b/se5/BritishToAmerican/README.md index 3c4aee7..59944dd 100644 --- a/se5/BritishToAmerican/README.md +++ b/se5/BritishToAmerican/README.md @@ -5,6 +5,11 @@ opposite direction. Reuses the bundled word list (~1850 pairs) and the shared `EnglishVariantConverter` from [`Plugin-Shared`](../Plugin-Shared/) with `Direction = BrToUs`. +Word list pairs marked `only="UsToBr"` are skipped in this direction: their +British-side word is also standard American English (car, film, flat, lift, +torch...), so "converting" it would rewrite text that is already correct +American (issue [#14374](https://github.com/SubtitleEdit/subtitleedit/issues/14374)). + ## Build See `.github/workflows/british-to-american.yml`. diff --git a/se5/Plugin-Shared/EnglishVariantConverter.cs b/se5/Plugin-Shared/EnglishVariantConverter.cs index f02a468..b13e1c2 100644 --- a/se5/Plugin-Shared/EnglishVariantConverter.cs +++ b/se5/Plugin-Shared/EnglishVariantConverter.cs @@ -81,6 +81,15 @@ private void LoadBuiltInWordList() continue; } + // only="UsToBr" / only="BrToUs" restricts a pair to one direction. Used for + // vocabulary pairs whose "source" word is also standard in the target dialect + // (car, film, flat, lift...) - converting those would corrupt correct text. + var only = element.Attribute("only")?.Value; + if (only != null && !only.Equals(_direction.ToString(), StringComparison.OrdinalIgnoreCase)) + { + continue; + } + var (from, to) = _direction == EnglishVariantDirection.UsToBr ? (us, br) : (br, us); AddRule(from, to); diff --git a/se5/Plugin-Shared/WordList.xml b/se5/Plugin-Shared/WordList.xml index b469cd6..f347487 100644 --- a/se5/Plugin-Shared/WordList.xml +++ b/se5/Plugin-Shared/WordList.xml @@ -14,7 +14,7 @@ - + @@ -61,8 +61,8 @@ - - + + @@ -246,8 +246,8 @@ - - + + @@ -401,7 +401,7 @@ - + @@ -548,7 +548,6 @@ - @@ -621,12 +620,12 @@ - + - - + + @@ -688,7 +687,7 @@ - + @@ -757,9 +756,8 @@ - + - @@ -878,8 +876,8 @@ - - + + @@ -1231,14 +1229,14 @@ - - - - - - - - + + + + + + + +