mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 14:30:52 +00:00
fix(i18n): strip the decoration around a name, not every protected span
prose() is built to measure prose, and a name is not prose. Comparing against it went wrong in both directions: n8n became nn because masking treats the digit as a span of its own, Infinito.Nexus became empty because the whole name reads as a domain, and Redis ``cache`` became Redis, which withheld 131 messages that say more than a name. _bare() removes only what a page wraps around the name: emphasis at the edges, a link when it is the whole message, and trailing symbols. The symbol loop walks the unicode categories rather than a character list, because an emoji is several codepoints, and it catches the heading that writes Git 🔐. A link counts only when nothing else is there, or 'See [Mastodon](...) and more.' would read as a name. Measured against the previous catalogs: 24 wrongly withheld messages return, n8n disappears in its three forms, zero warnings. The five reported cases - [Baserow](roles/web-app-baserow/), [API](roles/web-svc-api/), Git 🔐, Lint 🔍 and n8n - were looked up in the catalog and are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b7bfc90469
commit
d061ba3bb5
2 files changed
+70
-10
No files matched your search
@@ -33,6 +33,15 @@ class TestUntranslatable(unittest.TestCase):
|
||||
with self.subTest(marked):
|
||||
self.assertTrue(untranslatable(marked))
|
||||
|
||||
def test_a_name_carrying_a_digit_survives_the_stripping(self) -> None:
|
||||
for written in ("n8n", "**n8n**", "Mini-QR"):
|
||||
with self.subTest(written):
|
||||
self.assertTrue(
|
||||
untranslatable(written),
|
||||
"comparing against the prose left 'nn', because masking "
|
||||
"treats the digit as a span of its own",
|
||||
)
|
||||
|
||||
def test_the_name_is_matched_whatever_case_the_page_wrote_it_in(self) -> None:
|
||||
self.assertTrue(
|
||||
untranslatable("**mailu**"),
|
||||
@@ -40,6 +49,31 @@ class TestUntranslatable(unittest.TestCase):
|
||||
"product is Mailu either way",
|
||||
)
|
||||
|
||||
def test_a_link_whose_text_is_the_name_is_withheld(self) -> None:
|
||||
for written in (
|
||||
"[Baserow](roles/web-app-baserow/)",
|
||||
"[Mastodon](https://joinmastodon.org)",
|
||||
):
|
||||
with self.subTest(written):
|
||||
self.assertTrue(untranslatable(written))
|
||||
|
||||
def test_an_emoji_behind_the_name_does_not_hide_it(self) -> None:
|
||||
for written in ("Git 🔐", "Claude Code 🤖"):
|
||||
with self.subTest(written):
|
||||
self.assertTrue(untranslatable(written))
|
||||
|
||||
def test_a_message_saying_more_than_the_name_is_translated(self) -> None:
|
||||
for written in ("Redis ``cache``", "Redis `queue`", "[Documentation](docs/)"):
|
||||
with self.subTest(written):
|
||||
self.assertFalse(
|
||||
untranslatable(written),
|
||||
"stripping every protected span instead of the decoration "
|
||||
"withheld 131 messages that say more than a name",
|
||||
)
|
||||
|
||||
def test_a_link_inside_a_sentence_is_translated(self) -> None:
|
||||
self.assertFalse(untranslatable("See [Mastodon](https://x) and more."))
|
||||
|
||||
def test_a_marked_up_description_is_still_translated(self) -> None:
|
||||
self.assertFalse(untranslatable("**Cleanup Disc Space**"))
|
||||
|
||||
|
||||
Reference in new issue
Block a user