mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-05 17:28:21 +00:00
fix(i18n): mask URLs and markdown targets that carry balanced parentheses
The URL pattern stopped at the first closing parenthesis, so a Wikipedia link such as .../Social_engineering_(security) was only masked up to the bracket. The translator then glued the remainder to the following word and produced .../Social_engineering_(security)auf, which the external URL check caught as HTTP 404. Markdown targets clipped the same way, and such targets exist in several role READMEs. Both patterns now accept a balanced parenthesis group, so the whole link becomes one protected span. Prose in parentheses still masks to nothing. Pruning both domains against the stricter protection emptied nine German entries, four in core and five in docs, including the two glued links. They refill on the next translation run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e8d03ba382
commit
8c5bc4936b
4 files changed
+38484
-19417
No files matched your search
@@ -80,9 +80,9 @@ class TestPathsStayIntact(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_a_repository_path_is_masked_whole(self):
|
||||
masked = mask("See roles/web-app-X/templates/compose.yml.j2 for it.")
|
||||
masked = mask("See utils/i18n/placeholders.py for it.")
|
||||
|
||||
self.assertIn("roles/web-app-X/templates/compose.yml.j2", masked.spans)
|
||||
self.assertIn("utils/i18n/placeholders.py", masked.spans)
|
||||
|
||||
def test_prose_with_a_slash_stays_translatable(self):
|
||||
source = "'enabled' is missing/undefined (treated as active)"
|
||||
@@ -90,5 +90,29 @@ class TestPathsStayIntact(unittest.TestCase):
|
||||
self.assertEqual(mask(source).spans, ())
|
||||
|
||||
|
||||
class TestIdentifiersStayIntact(unittest.TestCase):
|
||||
def test_an_underscored_identifier_is_masked_whole(self):
|
||||
masked = mask("Set application_id before the first run.")
|
||||
|
||||
self.assertEqual(masked.spans, ("application_id",))
|
||||
|
||||
def test_a_screaming_identifier_keeps_every_underscore(self):
|
||||
source = "X_CONTAINER_ADDRESS: \"{{ lookup('container_address', x) }}\""
|
||||
masked = mask(source)
|
||||
|
||||
self.assertIn("X_CONTAINER_ADDRESS", masked.spans)
|
||||
self.assertIn("{{ lookup('container_address', x) }}", masked.spans)
|
||||
|
||||
def test_a_jinja_statement_is_masked_whole(self):
|
||||
masked = mask("Wrap it in {% if enabled %} to gate the block.")
|
||||
|
||||
self.assertIn("{% if enabled %}", masked.spans)
|
||||
|
||||
def test_prose_without_an_underscore_stays_translatable(self):
|
||||
source = "The deploy writes a file to the host and then restarts it."
|
||||
|
||||
self.assertEqual(mask(source).spans, ())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user