From 879eecacad62aec09f38ed0c1856d94d7f8e4763 Mon Sep 17 00:00:00 2001 From: Filipe Moreira <108258235+lippdev@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:36:32 +0200 Subject: [PATCH] test: fail when a translation copies an English sentence Key parity and placeholders were already checked, but a value pasted in English (as the minimize-to-tray strings were before #151) passed. Phrases of three or more words that match en-US now fail; single words and product names are allowed. Co-Authored-By: Claude Opus 5.5 --- tests/ConsoleMode.Tests/LocalizationTests.cs | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/ConsoleMode.Tests/LocalizationTests.cs b/tests/ConsoleMode.Tests/LocalizationTests.cs index d81c42f..bb83a38 100644 --- a/tests/ConsoleMode.Tests/LocalizationTests.cs +++ b/tests/ConsoleMode.Tests/LocalizationTests.cs @@ -82,6 +82,33 @@ public void Catalog_placeholders_match_english() } } + /// Names that read the same in every language (products, the desktop shortcut). + private static readonly HashSet SameInEveryLanguage = + ["Brand", "ShortcutName", "LaunchSteam", "FpsOverlayShowApi"]; + + private static readonly Regex WordPattern = new(@"\p{L}{2,}", RegexOptions.Compiled); + + [Fact] + public void Translations_do_not_copy_english_sentences() + { + // Single words ("Volume", "Desktop", "FPS") can legitimately match English; a phrase of + // three or more words that matches is an English text pasted in and never translated. + var english = LoadCatalog(LocalizationService.EnglishUnitedStates); + var copied = new List(); + foreach (var language in LocalizationService.SupportedLanguages + .Select(l => l.Code) + .Where(code => code != LocalizationService.EnglishUnitedStates)) + { + var localized = LoadCatalog(language); + copied.AddRange(english + .Where(entry => !SameInEveryLanguage.Contains(entry.Key) + && WordPattern.Matches(entry.Value).Count >= 3 + && localized[entry.Key] == entry.Value) + .Select(entry => $"{language}:{entry.Key}")); + } + Assert.True(copied.Count == 0, $"Untranslated (same as en-US): {string.Join(", ", copied)}"); + } + [Fact] public void Display_mode_labels_follow_the_language_switch() {