fix(i18n): let the shared predicate cover what the catalog lint reports

test_i18n_catalogs.py:125 and :141 report a translation whose emphasis carries a space or whose sentence boundary was swallowed, and the first one's failure message says to run prune and translate again. prune clears through damaged(), which did not know either criterion, so those entries survived every prune and the advice was impossible to follow.

Add both to harms(). The writer does not get stricter: unmask() applies tighten and resegment as repairs before it asks harms(), so a freshly written entry satisfies them by construction, and a test pins that. Measured over every checked-in catalog, 581220 translated entries: 599 condemned before, 599 after, 0 newly condemned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5 committed 2026-09-25 14:50:25 +02:00
1 parent cff899a531
commit 9679fa4221
2 files changed
+22 -1

No files matched your search

+20 -1
View File
@@ -8,7 +8,6 @@ lower-cased, and a run of spaces it opened around a span.
from __future__ import annotations
import unittest
from typing import ClassVar
from utils.i18n.placeholders import (
@@ -18,6 +17,7 @@ from utils.i18n.placeholders import (
recapitalise,
resegment,
terminate,
tighten,
truncated,
unmask,
)
@@ -176,6 +176,25 @@ class TestWriterAndGateAgree(unittest.TestCase):
self.assertFalse(harms(self.SOURCE, faithful))
self.assertEqual(_round_trip(self.SOURCE, faithful), faithful)
def test_prune_can_clear_what_the_repository_lint_reports(self) -> None:
source = "**bold** text here and more words to say"
spaced = "** fett ** Text hier und mehr Worte zu sagen"
self.assertNotEqual(tighten(spaced), spaced, "the lint would report this")
self.assertTrue(harms(source, spaced), "so damaged() must report it too")
def test_a_repaired_translation_is_not_reported_by_the_widened_predicate(
self,
) -> None:
source = "All `alpha` criteria."
restored = _round_trip(source, 'alle <x id="0"></x> Kriterien')
self.assertEqual(restored, "Alle `alpha` Kriterien.")
self.assertFalse(
harms(source, restored),
"the repairs run before harms(), so a written entry must stay clean",
)
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 (
+2
View File
@@ -249,6 +249,8 @@ def harms(source: str, translation: str) -> bool:
or missing_names(source, translation)
or truncated(source, translation)
or structure(translation) != structure(source)
or tighten(translation) != translation
or resegment(translation, mask(source).spans, source) != translation
)