diff --git a/cli/build/i18n/__main__.py b/cli/build/i18n/__main__.py index b45d382246..5a1c9d8b91 100644 --- a/cli/build/i18n/__main__.py +++ b/cli/build/i18n/__main__.py @@ -125,7 +125,7 @@ def prune(domains: list[str], requested: list[str]) -> int: catalog = read_catalog(path) shared = over_shared(catalog) discard(shared) - broken = damaged(catalog) + broken = damaged(catalog, code) discard(broken) if not shared and not broken: continue diff --git a/tests/integration/i18n/test_catalogs_complete_on_gpu.py b/tests/integration/i18n/test_catalogs_complete_on_gpu.py index 0a7a2e061b..e3f56b7185 100644 --- a/tests/integration/i18n/test_catalogs_complete_on_gpu.py +++ b/tests/integration/i18n/test_catalogs_complete_on_gpu.py @@ -44,7 +44,9 @@ def measure(task: tuple[str, str]) -> Counts: """ name, path = task catalog = read_catalog(Path(path)) - return Counts(name, len(pending(catalog)), len(damaged(catalog))) + return Counts( + name, len(pending(catalog)), len(damaged(catalog, name.split("/")[1])) + ) @unittest.skipUnless(accelerated(), "no NVIDIA runtime on this host") diff --git a/tests/unit/python/utils/i18n/test_translate.py b/tests/unit/python/utils/i18n/test_translate.py index 4cc92948d9..f054a92523 100644 --- a/tests/unit/python/utils/i18n/test_translate.py +++ b/tests/unit/python/utils/i18n/test_translate.py @@ -323,7 +323,7 @@ class TestDamagedMarkup(unittest.TestCase): "Siehe [den Leitfaden]](docs/guide.md) zuerst.", ) - self.assertEqual(len(damaged(catalog)), 1) + self.assertEqual(len(damaged(catalog, "de")), 1) def test_a_dropped_bracket_is_damage(self): catalog = self._catalog( @@ -331,7 +331,7 @@ class TestDamagedMarkup(unittest.TestCase): "!Logo](assets/img/logo.png)", ) - self.assertEqual(len(damaged(catalog)), 1) + self.assertEqual(len(damaged(catalog, "de")), 1) def test_an_intact_translation_is_not_damage(self): catalog = self._catalog( @@ -339,7 +339,7 @@ class TestDamagedMarkup(unittest.TestCase): "Siehe [den Leitfaden](docs/guide.md) zuerst.", ) - self.assertEqual(damaged(catalog), []) + self.assertEqual(damaged(catalog, "de"), []) class TestDuplicateTranslation(unittest.TestCase): diff --git a/utils/i18n/translate.py b/utils/i18n/translate.py index 921ad2a7e6..cca83e8c2c 100644 --- a/utils/i18n/translate.py +++ b/utils/i18n/translate.py @@ -103,7 +103,7 @@ def pending(catalog: Catalog) -> list[Message]: ] -def damaged(catalog: Catalog) -> list[Message]: +def damaged(catalog: Catalog, language: str) -> list[Message]: """Return the entries whose translation altered a protected span or the markup around it. A tightened protection rule turns silently corrupted translations - a @@ -112,10 +112,15 @@ def damaged(catalog: Catalog) -> list[Message]: what masking cannot: a bracket the translator added or dropped next to a protected span leaves every span intact and still breaks the link. + The language is the caller's, never ``catalog.locale``: 44 catalogs carry + no locale header at all, and 6 more name a code the directory disagrees + with (``tl`` holds ``fil_PH``), so reading it there turns the script check + into a no-op for exactly the catalogs nothing else guards. + Args: catalog: a language catalog. + language: the ISO code the catalog's path names. """ - language = str(catalog.locale or "").split("_")[0] return [ message for message in catalog