mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
A link whose label is its own target's filename is a path, not prose: [11_oidc.yml](../../group_vars/all/11_oidc.yml) comes back with a translated filename. The markup rule lets it through because the extension contributes letters, so it needs its own shape. A label that says something about the target keeps its translation, which is what separates it from [the OIDC defaults](../../group_vars/all/11_oidc.yml). A message that is one technical token reads the same everywhere: an abbreviation in capitals, a version, or a run of command-line options. Together with the link rule this withholds 102 messages the catalogs used to send, 34 tokens and 68 changelog links, every one of them read before it landed here. Known limit: ABBREVIATION matches any capitalised word of three or more characters, so it reaches messages that do not exist yet. MUST, TODO and TODOS are already words rather than abbreviations, and a future UI label like ERROR would be withheld the same way. The failure mode is silent, since a wrongly withheld message simply stays English without any test going red. Narrowing it to tokens the repository also uses as identifiers is the open follow-up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
140 lines
5.8 KiB
Python
140 lines
5.8 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from utils.i18n.untranslatable import is_name, untranslatable
|
|
|
|
|
|
class TestUntranslatable(unittest.TestCase):
|
|
def test_a_message_without_a_word_is_withheld(self) -> None:
|
|
self.assertTrue(untranslatable("[`e2e/`](e2e/)"))
|
|
|
|
def test_a_brand_on_its_own_is_withheld(self) -> None:
|
|
self.assertTrue(untranslatable("Mastodon"))
|
|
|
|
def test_a_credited_person_is_withheld(self) -> None:
|
|
self.assertTrue(untranslatable("Kevin Veen-Birkenbach"))
|
|
|
|
def test_the_software_itself_is_withheld(self) -> None:
|
|
for written in ("Infinito.Nexus", "**Infinito.Nexus**", "infinito.nexus"):
|
|
with self.subTest(written):
|
|
self.assertTrue(untranslatable(written))
|
|
|
|
def test_a_sentence_about_the_software_is_translated(self) -> None:
|
|
self.assertFalse(untranslatable("Infinito.Nexus is a platform."))
|
|
|
|
def test_a_bare_url_is_withheld(self) -> None:
|
|
for address in ("https://veen.world", "www.veen.world", "mailto:a@b.c"):
|
|
with self.subTest(address):
|
|
self.assertTrue(untranslatable(address))
|
|
|
|
def test_markdown_around_the_brand_does_not_hide_it(self) -> None:
|
|
for marked in ("**Mastodon**", "*Mastodon*", "`Mastodon`"):
|
|
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**"),
|
|
"a page writes the name the way its sentence needs it, and the "
|
|
"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**"))
|
|
|
|
def test_a_brand_inside_a_marked_up_sentence_is_translated(self) -> None:
|
|
self.assertFalse(untranslatable("See **Mastodon** here."))
|
|
|
|
def test_a_sentence_carrying_the_brand_is_translated(self) -> None:
|
|
self.assertFalse(
|
|
untranslatable("Mastodon is a federated social network."),
|
|
"inside a sentence the name is protected by the span machinery and "
|
|
"the sentence around it still needs translating",
|
|
)
|
|
|
|
def test_a_descriptive_title_is_translated(self) -> None:
|
|
self.assertFalse(untranslatable("Cleanup Disc Space"))
|
|
|
|
def test_an_ordinary_heading_is_translated(self) -> None:
|
|
self.assertFalse(
|
|
untranslatable("Documentation"),
|
|
"a role title that is an ordinary word is not a brand: no upstream "
|
|
"identifier of that role carries it",
|
|
)
|
|
|
|
def test_a_url_inside_prose_is_not_a_name(self) -> None:
|
|
self.assertFalse(is_name("See https://veen.world for details."))
|
|
|
|
def test_surrounding_whitespace_does_not_hide_a_name(self) -> None:
|
|
self.assertTrue(untranslatable(" Mastodon \n"))
|
|
|
|
def test_a_link_labelled_with_its_own_filename_is_withheld(self) -> None:
|
|
for written in (
|
|
"[000.005.000-2025-12-30.md](docs/changelog/000.005.000-2025-12-30.md)",
|
|
"[11_oidc.yml](../../../../group_vars/all/11_oidc.yml)",
|
|
"[CODEOWNERS](.github/CODEOWNERS)",
|
|
"[ruff](https://github.com/astral-sh/ruff)",
|
|
):
|
|
with self.subTest(written):
|
|
self.assertTrue(untranslatable(written))
|
|
|
|
def test_a_link_that_says_something_about_its_target_is_sent(self) -> None:
|
|
self.assertFalse(
|
|
untranslatable("[the OIDC defaults](../../group_vars/all/11_oidc.yml)")
|
|
)
|
|
|
|
def test_an_abbreviation_on_its_own_is_withheld(self) -> None:
|
|
for written in ("DKIM", "OIDC", "RBAC", "SMTP"):
|
|
with self.subTest(written):
|
|
self.assertTrue(untranslatable(written))
|
|
|
|
def test_a_version_on_its_own_is_withheld(self) -> None:
|
|
for written in ("v2026.7.20", "18.x", "1.2.3-rc1"):
|
|
with self.subTest(written):
|
|
self.assertTrue(untranslatable(written))
|
|
|
|
def test_a_run_of_options_is_withheld(self) -> None:
|
|
self.assertTrue(untranslatable("--distro debian --owner acme --tag ci-abc"))
|
|
|
|
def test_a_sentence_naming_an_abbreviation_is_still_sent(self) -> None:
|
|
self.assertFalse(untranslatable("The DKIM record is missing."))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|