feat(i18n): reject stuttered and still-Latin translations

The server answers a failed call with its input, sometimes lightly
reworded and sometimes with a word repeated. Both shapes pass every
existing criterion: the protected spans survive, the markup count
survives, it is no echo, and truncated() only watches the short side.

stutters() reports a word the translation repeats three times in a row
and the source does not. untranslated() reports a non-Latin target whose
prose is at least 90% ASCII words, which needs the catalog language, so
harms() and unmask() now take it and client.py passes its target through.

Measured over 580079 translated entries: 3650 stutters, 611 still in
Latin script, 2 both, 4259 newly reported. None of the source messages
repeats a word three times itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-25 16:26:51 +02:00
1 parent 9d1b0f4f5a
commit e38c33a791
4 files changed
+89 -5

No files matched your search

@@ -222,6 +222,32 @@ class TestWriterAndGateAgree(unittest.TestCase):
"count as translated and never be retried",
)
def test_a_stuttered_word_is_reported(self) -> None:
self.assertTrue(harms("Cloud", "Cloud Cloud Cloud"))
self.assertTrue(
harms("Marketing for teams", "Marketing Marketing Marketing für Teams")
)
def test_a_word_the_source_repeats_is_not_a_stutter(self) -> None:
source = "very very very slow"
self.assertFalse(harms(source, source.replace("slow", "langsam")))
def test_a_non_latin_catalog_that_came_back_in_english_is_reported(self) -> None:
english = "Core NGINX webserver with stream support and tuned defaults"
self.assertTrue(harms(english, english.replace("tuned", "tunned"), "ar"))
self.assertFalse(
harms(english, english.replace("tuned", "tunned"), "de"),
"a latin-script target needs a language detector, which does not exist here",
)
def test_a_non_latin_translation_keeping_a_few_terms_is_not_reported(self) -> None:
source = "Core NGINX webserver with HTTP stream support and tuned defaults"
arabic = "خادم NGINX الأساسي مع دعم HTTP وإعدادات افتراضية مضبوطة للأداء"
self.assertFalse(harms(source, arabic, "ar"))
def test_every_criterion_of_the_gate_reaches_the_client(self) -> None:
named = "Deploy web-app-docs before the documentation site answers anything."
for label, source, translation in (